in the jQuery mobile example. The page that will be displayed after a form is submitted is the same as where the form will be POST-ing/GET-ing to.
Is it posible to submit forms to a URL and transit to another page inside the DOM?
You can add an event handler for the submit event for the form and submit the form manually, then manually transition to whatever page you want.
$(function () {
$('#form_id').bind('submit', function (e) {
e.preventDefault();
$.post('path/to/file.php', $(this).serialize(), function (response) {
$.mobile.changePage('#page_to_goto', {transition: 'slide'});
});
});
});
Some Notes:
data-ajax="false" to the form tag.e.preventDefault() stops the form from submitting normally, a return false; at the end of the event handler should do the same thing.$.post - http://api.jquery.com/jQuery.post/.serialize() - http://api.jquery.com/serialize/$.mobile.changePage() - http://jquerymobile.com/demos/1.0rc1/docs/api/methods.htmlIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With