javascript - Razor form on a facebook tab page -
i trying execute form inside facebook tab. have tried among many things:
it seems request.httpmethod == "post" not working usual. @message prints out on pageload. have tried add alert before return $('form').valid(). not being executed.
any ideas of issue or workaround.
code:
@{ var message = string.empty; if (request.httpmethod == "post") { message = "submitted"; } } <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> <div class="form"> @if (!string.isnullorempty(message)) { <p class="formfinish"> @message </p> } <div class="row"> <label>name</label> <input type="text" name="name" id="name" class="required" minlength="4" maxlength="30" /> </div> <div class="newgame row"> <button class="btn">submit</button> </div> </div> <script type="text/javascript"> $(document).ready(function () { $('form').attr('enctype', "multipart/form-data"); $('form').on('submit', function () { return $('form').valid() }); }); </script>
i might missing obvious, doesn't seem you're sending post. you've got no actual form there, div class of "form", , "submit" button button doesn't appear have action associated it. you're going need post if want page post request.
edit: here's working code, had change "div class='form'" actual form element method "post". note didn't fix usage of jquery validate, form generating post request, should on way.
@{ var message = string.empty; if (request.httpmethod == "post") { message = "submitted"; } } <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script> <form method="post"> @if (!string.isnullorempty(message)) { <p class="formfinish"> @message </p> } <div class="row"> <label>name</label> <input type="text" name="name" id="name" class="required" minlength="4" maxlength="30" /> </div> <div class="newgame row"> <input type="submit" class="btn" value="submit" /> </div> </form>
Comments
Post a Comment