[英]How to add post parameters to $.ajax and $.ajaxSubmit
I used the ajax method of jquery for my forms. 我为表单使用了jquery的ajax方法。 but now I need to add a field to the function.
但是现在我需要向该函数添加一个字段。
how can I have my forms fields and my new post parameter. 如何获得表单字段和新的post参数。
var frm = $(n);
$.ajax({
type: frm.attr('method'),
url: frm.attr('action'),
//contentType:frm.attr('enctype'),
data: frm.serialize(),
success: function (data) {
$(dataform).html(data);
$(des).html('');
$("button[type='submit']").attr('disabled',null);
}
});
the data
parameter should be like this: data
参数应如下所示:
data: frm.serialize() + {'foo':'bar'}
thanks in advance. 提前致谢。
.serialize()
返回一串参数,就像在查询字符串中看到的那样,因此只需加上+ "&foo=bar"
尝试这样的事情
data: frm.serialize()+'&foo=bar',
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.