ajax以json格式传递json数据和数组数据

2018-10-30 16:31 更新

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 );

    
    }
}
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号