如果處理表單提交與定製submit
事件處理程序,您可以在同一頁面上處理驗證:
//bind an event handler to the submit event for your login form
$(document).on('submit', '#form_id', function (e) {
//cache the form element for use in this function
var $this = $(this);
//prevent the default submission of the form
e.preventDefault();
//run an AJAX post request to your server-side script, $this.serialize() is the data from your form being added to the request
$.post($this.attr('action'), $this.serialize(), function (responseData) {
//in here you can analyze the output from your server-side script (responseData) and validate the user's login without leaving the page
});
});
從運行表單自身的AJAX sumbission停止jQuery Mobile的把這個表單標籤:
<form data-ajax="false" action="...">
任何反饋的反對票將不勝感激。我只是想知道我在做什麼錯:) – Jasper
所以我;-)唯一可能的是,'生活'現在已被棄用,你應該使用'開'。也許甚至'開/關'的順序,以防止重複的事件:http://stackoverflow.com/questions/9067259/ –