我想向验证服务器端脚本发送一个额外的参数。我有这段代码:
$("#edit_info").validate({
debug: false,
rules: {
name: {
required: true,
//remote: "validate.php",
remote: { url:"validate.php", async:false },
data: {'cat_id':'34'}
/*data: {
cat_id: function () { return '34'; }
}*/
},
但只有名字才会被发送。知道为什么吗? 谢谢!
答案 0 :(得分:5)
如果您想发送动态参数,而不是静态:
$("#edit_info").validate({
debug: false,
rules: {
name: {
required: true,
remote: {
url:"validate.php",
data: {'cat_id':function(){return $('#otherelement').val()}},
async:false
}
},
答案 1 :(得分:4)
找出问题所在。数据必须在远程标签内......
$("#edit_info").validate({
debug: false,
rules: {
name: {
required: true,
remote: {
url:"validate.php",
data: {'cat_id':'34'},
async:false
}
},