codecamp

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

    
    }
}
ajax以java封装的model对象传值方式
复选框(checkbox)总结
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

Ueditor

My97 DatePicker

Dtree——Js树型控件

浏览系

无标题目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }