$.fn.serializeForJSON = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
$.ajax({
type: "post",
url: "*******",
data: JSON.stringify($("#jxForm").serializeForJSON()),//$("#jxForm").serializeArray(),
dataType: 'json',
contentType: "application/json",
success: function (rst) {
console.log(rst);
if (rst.code == 0) {
layer.msg(rst.msg, {time: 1000}, function () {
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index); //再执行关闭
parent.searchData();
});
} else {
layer.msg(rst.msg, {time: 1000}, function () {
});
}
}
});正文
form表单序列化转换JSON
这篇文章最后更新于1981天前,您需要注意相关的内容是否还可用,如有疑问请联系作者!
文章版权声明:除非注明,否则均为华仔部落原创文章,转载或复制请以超链接形式并注明出处。

还没有评论,来说两句吧...