$('#inputForm').serializeArray() 爲對象數組json
$('#inputForm').serialize() 爲json字符串數組
若是要處理對象的屬性,例如過濾,建議使用serializeArray,處理後爲obj數組,轉爲json字符串orm
var allFields = $('#inputForm').serializeArray();對象
var custFields = getCustFieldByFilterField(allFields); 字符串
轉化爲json字符串get
var custFieldsJson = {};
$.each(custFields,function(i,v){
obj[v.name] = v.value;
);input
//過濾字段
function getCustFieldByFilterField(data){
var custFields = new Array();
for(var i=0;i<data.length;i++){
var fieldName = data[i].name;
if(fieldName.indexOf("defCustomer")>=0){
custFields.push(data[i]);
}
}
return custFields;
}io