表单仍在提交的原因是什么?验证检查工作,但如果一切都输入正确,表单提交和Ajax请求不会触发。jquery:返回:提交时不起作用 - 表单仍提交
$("#formRegister").submit(function() {
// Start problem
var mode = $("registerMode").val();
// End problem
var username = $("#registerUsername").val();
var password = $("#registerPassword").val();
var passwordConfirm = $("#registerPasswordConfirm").val();
var avatar = $("#registerAvatar").val();
if (username == 'Username') {
$("#registerError").html('You must enter a username');
} else if (password == 'Password') {
$("#registerError").html('You must enter a password');
} else if (password != passwordConfirm) {
$("#registerError").html('Your passwords did not match');
} else if (avatar == 'Avatar URL') {
$("#registerError").html('You must enter the URL for your combine avatar');
} else {
$.ajax({
type: "POST",
url: "processUsers.php",
data: {
mode: mode,
username: username,
password: password,
avatar: avatar
},
dataType: "JSON",
success: function(data) {
alert('success!');
}
});
}
return false;
});
可以请您给HTML太 – Puneet
哪里变量被宣布为“数据”选项? – hex4
您的浏览器控制台中的任何错误 –