//bind event handler to the form for the `submit` event
$('form').bind('submit', function () {
//cache the form element for use later
var $form = $(this);
//show loading message
$.mobile.showLoadingMsg();
//create an AJAX request using the form's attributes as settings
$.ajax({
url : $form.attr('action'),
type : $form.attr('method'),
data : $form.serialize(),//this serializes the form's data for transmission
success : function (serverResponse) {
//now hide the loading message because the AJAX call is done
$.mobile.hideLoadingMsg();
//and redirect the user to the specified page,
//I am just forwarding the user to the value of the toggle
//but you can create an if/then statement that directs the user to the proper page
$.mobile.changePage($('#' + $form.find('.ui-slider-switch').val()));
}
});
//return false to stop the default submission of the form
return false;
});
Вам также необходимо отключить автоматическую обработку формы AJAX, это можно сделать, добавив data-ajax="false"
к тегу form
:
<form action="..." data-ajax="false" method="...">