ajax以json格式传递json数据和数组数据
1.js代码
function update_save(frId,tabId){
var formData = $('#'+frId).serializeArray();
var brgKeyList = ["bridgeaqttype","bridgeqdtype","bridgezztype","bridgethgrade","bridgedtfzsstype"];
var bridges =[{"deptcode":"4121091","deptname":"开发区住建局","cityname":"许昌市"}]; ;
var jsonData= {"brgKeyList[]":brgKeyList,"brgeJStr":JSON.stringify(bridges)};
$.ajax({
url : 'bridge_test.fdo',
type : "POST",
data :jsonData,
// async : false,
dataType : 'json',
success : function(returndate, status) {
debugger;
dateObj = eval('(' + returndate + ')');
var flag = dateObj.flag;
var msg = dateObj.msg;
alert('modifyPan',' 修改数据',msg);
}
});
}
2.java代码(action层)
public class TBridgeAction{
private String[] brgKeyList;
private String brgeJStr;
get,set方法省略.....
public String tableModify() throws Exception{
JSONArray jsonList = JSONArray.fromObject(brgeJStr );
}
}