In jQuery Mobile, form submissions are automatically handled using Ajax whenever possible, creating a smooth transition between the form and the result page. To ensure your form submits as intended, be sure to specify
method properties on your form element. When unspecified, the method will default to
get, and the
action will default to the current page's relative path (found via
Forms also accept attributes for transitions just like anchors, such as
data-direction="reverse". To submit a form without Ajax, you can either disable Ajax form handling globally, or per form via the
data-ajax="false" attribute. The
target attribute (as in
target="_blank") is respected on forms as well, and will default to the browser's handling of that target when the form submits. Note that unlike anchors, the
rel attribute is not allowed on forms.
To prevent form submissions from being automatically handled with Ajax, add the
data-ajax="false" attribute to the form element. You can also turn of Ajax form handling completely via the
ajaxFormsEnabled global config option.
This page demonstrates automated ajax handling of form submissions. The form below is configured to send regular a
get request to
forms-sample-response.php. On submit, jQuery Mobile will make sure that the Url specified is able to be retrieved via Ajax, and handle it appropriately. Keep in mind that just like ordinary HTTP form submissions, jQuery Mobile allows
get result pages to be bookmarked by updating the Url hash when the response returns successfully. Also like ordinary form submissions,
post requests do not contain query parameters in the hash, so they are not bookmarkable.