mootools 针对JSON对象的AJAX操作

List<Operator>

 

java:

JSONArray ja = new JSONArray();

List<Operator> operatorsList = sysManageOrganiseFacade.queryOperateOrderByBustypeAndOrgid(businesstypeTemp,

                   Constants.ROLE_BUSINESSDIRECTOR, organsie.getOrganiseid());// 得到当前部门操作员列表

for (Operator p : operatorsList) {

         JSONObject jo = new JSONObject(p);

         ja.put(jo);

}

singleData = ja.toString();

 

js:

function getAuditList(obj){

         var jsonRequest = new Request.JSON({

                   url:"adjust-charge-handle!queryAduitList.action", 

                   onComplete:function(responseText,txt){

                   var data = JSON.decode(txt);

 

                   $each(data, function(item){

                            item.operatorcode;

                            item.operatorname;

                   });

         }}).get({"businesstype":obj.BUSINESSTYPE});

}

 

 

List<Map<String,Object>>

 

java:

List<Map<String,Object>> listpdata = this.facade.getSendPlaninfoByPlanid(sendplanid);

JSONArray ja = new JSONArray();

for (Map<String,Object> map : listpdata) {

         JSONObject jo = new JSONObject(map);

         ja.put(jo);

}

this.singleData = ja.toString();

 

 

js:

var ajax = new Request.JSON( {

                   url : "dun-plan-exec!getSendPlanInfoByPlanid.action",

                   method : 'get',

                   onSuccess : function(obj,responsetxt) {

                    var data = JSON.decode(responsetxt);

                       data.each(function(item){

                                     tem.SPNAME;

                                     newTd1.innerHTML = item.MSGINFO;

                            });              

                   }

}).get({"sendplanid":sid});       

 

Map<String, Object>

 

java:

Map<String, Object> jsonMap = this.facade.updateDunDataState(dunnid, "del");

JSONObject jo = new JSONObject(jsonMap);

this.singleData = jo.toString();

 

js:

var ajax = new Request.JSON( {

                   url : "dun-plan-exec!cancelPlanDetail.action",

                   method : 'get',

                   onSuccess : function(obj,responsetxt) {

                    var data = JSON.decode(responsetxt);                            

                    if(data.ret=='1')

                    {

                             alert("操作成功!");

                    }

                   else

                    {

                             alert("操作失败!");

                    }                                 

}).get({"sendplandetailid":did});     

你可能感兴趣的:(json,Ajax,mootools)