Возможно, вы захотите добавить обработчик .error () в пример Jasper, в противном случае, если в jquery или на стороне сервера будет ошибка, ваше загрузочное сообщение будет отображаться сверху, пока пользователь не обновит страницу, что, вероятно, вызовет многоиз данных, которые он ввел.
//add event handler to your form's submit event
$('form').on('submit', function (e) {
var $this = $(this);
//prevent the form from submitting normally
e.preventDefault();
//show the default loading message while the $.post request is sent
$.mobile.showPageLoadingMsg();
//send $.post request to server, `$this.serialize()` adds the form data to the request
$.post($this.attr('action'), $this.serialize(), function (response) {
//you can now access the response from the server via the `response` variable
$.mobile.hidePageLoadingMsg();
}, 'json') //you can set the response data-type as well
.error(function(e) {
$.mobile.showPageLoadingMsg();
console.log('my_function_name, ' + e.responseText);
});
});