标签:
$.fn.serializeObject = 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;
};
var jsonObj = $("#form").serializeObject(); //json对象
var jsonStr = JSON.stringify($("#form").serializeObject()); //json字符串
标签:
原文地址:http://www.cnblogs.com/chenweichu/p/5832633.html