我有一个jQuery移动窗体设置运行ajax请求。这个问题并不是要求,但是事实上,当发送提交时,jQuery Mobile会装载页面内容。这反过来意味着我添加到当前页面的错误然后在页面交换时被移除(如果你已经使用了jquery mobile,你会知道页面哈希等是如何工作的)。jquery mobile ajax表单提交加载替换页面上我的ammends
p.s将表单封装在非ajax类中将不起作用,因为它会阻止我的ajax运行。
这是我有它设置...
Register of Log In
JQuery的
$(function() {
var logInFormData = $('#logInForm');
$('#logInFor').submit(function(){
$.ajax({
url: 'http://www.mysite.co.uk/project/logIn/logIn.php',
type: 'post',
data: logInFormData.serialize(),
dataType: 'json',
crossDomain : true,
timeout: 5000,
success: function(logInReturn){
if(logInReturn.message[1]){
localStorage.clear();
$('form#logInForm').append("
" + logInReturn.message[1] + "
}
else if(logInReturn.message[2]){
localStorage.setItem('userHandle', logInReturn.message[2].userHandle);
localStorage.setItem('userId', logInReturn.message[2].userId);
window.location ='selectProject.html';
}
},
error: function(){
alert('There was an error loading the data. Contact the admin.');
}
});
});
});
,从而你可以从我的PHP我在添加一个div错误的结果看到页面,但这个页面然后换出并用一个相同的页面减去div。很烦人。我猜是有办法在页面交换后追加它?
谢谢。
2013-02-05
Andre