JQUEY 格式化表单数据转JSON格式
原$(selector).serialize() 无法直接通过JSON.stringify() 转成JSON格式(http://www.w3school.com.cn/jquery/ajax_serialize.asp)
//格式化
var prejson=$("#Form").serializeObject();
//等到JSON格式数据
var json=JSON.stringify(prejson);
$.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;
};