1.将多个json对象合并成一个json对象
var house=$("#house-form").serializeJson();
var contract=$("#owner_contract").serializeJson();
var allocation=$("#house_allocation").serializeJson();
$.extend(param, house,contract,allocation);
serializeJson 是封装的拼接json的js方法:
$.fn.serializeJson=function(){
var serializeObj={};
var array=this.serializeArray();
var str=this.serialize();
$(array).each(function(){
if(serializeObj[this.name]){
if($.isArray(serializeObj[this.name])){
serializeObj[this.name].push(this.value);
}else{
serializeObj[this.name]=[serializeObj[this.name],this.value];
}
}else{
serializeObj[this.name]=this.value;
}
});
return serializeObj;
};
更多推荐
所有评论(0)