jquery.validate从JSOn成功加载新页面
具有在处理表单提交后调用的函数。我正在使用jquery1.8和JQuery.validate 我有以下函数执行检查并处理对服务器的调用,并接收JSON成功回调:jquery.validate从JSOn成功加载新页面,jquery,Jquery,具有在处理表单提交后调用的函数。我正在使用jquery1.8和JQuery.validate 我有以下函数执行检查并处理对服务器的调用,并接收JSON成功回调: <input type="submit" value="Continue" name="submit_first" onclick="verifyPge();" /> }) 有什么想法吗?基本上,在完成UI验证并处理表单之后,我希望加载新页面,但使用JQuery页面加载并让JQ
<input type="submit" value="Continue"
name="submit_first" onclick="verifyPge();" />
})
有什么想法吗?基本上,在完成UI验证并处理表单之后,我希望加载新页面,但使用JQuery页面加载并让JQuery通过Ajax切换页面 确保在服务器中返回URL
// document DOM ready
$(function() {
// validate signup form on keyup and submit
$("#yourInfo").validate({
submitHandler: function(form){
// submit the form via ajax
$.post(
// your script
'script.php',
// your form in a serialized way your server can understand
form.serializeArray()[0],
// success function
function(url){
window.location.assign(url); // load the new URL
}
);
return false;
},
rules: {
month: {
required: true,
},
day: {
required: true,
},
year: {
required: true
},
},
messages: {
month: {
required: "Please select the month you were born",
},
day: {
required: "Please select the day you were born",
},
year: {
required: "Please select the year you were born",
},
errorElement: "div"
}
});
});
jQuery验证插件已经处理了表单提交,不需要在提交按钮中添加验证页面。在表单验证后,使用submitHandler是提交表单的正确方式。您缺少verifyPgeI中的内容,我必须使用worklight adapter检查是否可以将函数放在//您的脚本'script.php'中,验证仅用于UI字段,verifyPge将实际调用适配器调用。必须绑定submit按钮,以便jquery.validate完成它的工作,然后通过适配器将序列化数据发送到后端。。。如果成功,请转到下一页。但我喜欢剧本的发展方向。我明天会试一试,然后告诉你。谢谢
// document DOM ready
$(function() {
// validate signup form on keyup and submit
$("#yourInfo").validate({
submitHandler: function(form){
// submit the form via ajax
$.post(
// your script
'script.php',
// your form in a serialized way your server can understand
form.serializeArray()[0],
// success function
function(url){
window.location.assign(url); // load the new URL
}
);
return false;
},
rules: {
month: {
required: true,
},
day: {
required: true,
},
year: {
required: true
},
},
messages: {
month: {
required: "Please select the month you were born",
},
day: {
required: "Please select the day you were born",
},
year: {
required: "Please select the year you were born",
},
errorElement: "div"
}
});
});