保存
function getsubmit(){
//1.第一种形式
var fromData={};
$(“#search_form”).serializeArray().map(function(x){fromData[x.name]=x.value;});
var arr = [];
for(var values in fromData)
{
var obj = {};
obj.column = values;
obj.data = fromData[values];
arr.push(obj);
}
var json = {
“edit_data”: arr};
alert(“fromData:”+JSON.stringify(json) );
//{“edit_data”:[{“column”:”xm”,”data”:”sdf”},{“column”:”sj”,”data”:”sadf”},{“column”:”yx”,”data”:”asfda”}]}
//2.第二种形式
var fromData={};
$("#search_form").serializeArray().map(function(x){fromData[x.name]=x.value;});
var arr = [];
for(var values in fromData)
{
var obj = {};
obj[values] = fromData[values];
arr.push(obj);
}
var json = {
"edit_data": arr};
// {"edit_data":[{"xm":"dsfa"},{"sj":"sdfa"},{"yx":"sdfas"}]}
alert("fromData:"+JSON.stringify(json) );
}