问题描述
我有一个具有多个选择下拉列表name=select[]
的表单,该表单是通过Jquery Validation进行验证的,并且在成功验证后提交了处理程序调用Ajax,我想发送所有表单键,并且值也包含在数组form中,这是我的代码.
I have a form which have multiple select dropdown name=select[]
, and this form is validate from Jquery Validation and after successful validation Submit handler call Ajax i want to send all form keys and values also include in array form , Here is My Code .
function:submitHandler
{
$.ajax({
url: "processo.php",
type: "POST",
data: new FormData(this),
cache: false,
processData:false,
success: function(data)
{
$('#loading').hide();
$("#message").html(data);
}
});
}
现在,当验证成功完成时,新的FormData(this)无法识别表单ID.但是当我放入new Formdata($("#frmRegister")[0])
时,它会将变量发送到php而不是数组.我如何在new Formdata("#frmRegister")
之类的形式中定义表单ID.请记住,我在form中也有多个选择数组.
Now the when validation successfully done new FormData(this) not recognize form id.but when i put new Formdata($("#frmRegister")[0])
then its send variables to php but not array. How can i define form id in like new Formdata("#frmRegister")
.Remember please i also have mulitple select array in form .
推荐答案
submithandler
在.validate()
方法的内部,您将使用开发人员提供的form
参数.
The submithandler
goes inside of the .validate()
method and you would use the form
argument provided by the developer.
$('#myform').validate({
submitHandler: function(form) {
$.ajax({
url: "processo.php",
type: "POST",
data: new FormData($(form)),
cache: false,
processData: false,
success: function(data) {
$('#loading').hide();
$("#message").html(data);
}
});
return false;
},
// other options
});
这篇关于Ajax调用提交处理程序Jquery验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!