1. 程式人生 > >ajax傳引數json物件到後臺獲取

ajax傳引數json物件到後臺獲取

 

var data = {data:{name:'pxxx',
                    paramData:[{dataSource:'a1',table:'t1',field:'f1','r':[{name1:"01",p:''},{name2:"02",p:'10,100'},{name2:"01",p:''}]},
                        {dataSource:'a2',table:'t2',field:'f2','r':[{name1:"01",p:''},{name2:"02",p:'10,100'},{name3:"01",p:''}]}]
                }};
$.ajax({
    type:"POST",
    async:false,
    dataType:'json',
    contentType : "application/json",
    url:"matePxxx/addPxx",
    data: JSON.stringify(data),
    success:function (data) {

            }
});

@RequestMapping("/addPxx")
@ResponseBody
public Map<String,Boolean> addPxxx(@RequestBody JSONObject data){
   System.out.println(data);
  return map;
}
$.ajax({
                                                type:"post",
                                                dataType:"json",
                                                url:"DataSourceCheck/refreshDataSource",
                                                data:{dataSourceId:dsId},
                                                success: function(data){
                                                    
                                                }
                                            });

@RequestMapping("refreshDataSource")
    @ResponseBody
    public boolean refreshDataAction(String dataSourceId){
        return true;
    }