javascript - Submit button in a header fails to submit -
i'm developing jquery mobile app. in app there form user has submit , i've placed submit button in right side in header. when user done filling of form , taps on submit button class of "ui-btn-right"
, fails submit.
$(document).ready(function(){ $('.ui-btn-right').on('click', function(event) { $("#form1").on('submit',function(event){ event.preventdefault(); data = $(this).serialize(); $.ajax({ type: "post", url: "register.php", data: data }).success(function() { $("input[type=text]").val(""); }); }); }); });
html
<a href='#' class='ui-btn-right' id="button" >register</a>
just taking guess here, can't see markup. looks you're not submitting form when click button, you're wiring submit event. try this?
$(document).ready(function(){ $('.ui-btn-right').on('click', function(event) { $('#form1').submit(); }); $("#form1").on('submit',function(event){ event.preventdefault(); data = $(this).serialize(); $.ajax({ type: "post", url: "register.php", data: data }).success(function() { $("input[type=text]").val(""); }); }); });
Comments
Post a Comment