将json数据回显到form表单

var cpJsonToForm = function (json,formId) {
var serializeArray = $("#"+formId).serializeArray();
for(var i = 0 ; i < serializeArray.length ; i ++ ){
var name = serializeArray[i].name;
if(json[name]){
var value = json[name];
$("[name='"+name+"']").val(value);
}

}

};

转载于:https://blog.51cto.com/12165865/2112245

你可能感兴趣的:(json,javascript,java)