我正在尝试从ajax响应加载数据表,然后执行服务器端处理。
这是我从服务器收到的回复:
{"msg":null,"code":null,"status":null,"result":[{"aNumber":"3224193861","bNumber":"3215910681","cellID":"410-06-325-13123","dateTime":"2017-06-05 09:44:22.0","duration":778,"imei":"47350901163665","imsi":"33372328617146","operatorId":2,"mscId":"3","fileId":"2"},{"aNumber":"3224193861","bNumber":"3028540439","cellID":"410-01-737-38540","dateTime":"2017-04-26 18:53:23.0","duration":266,"imei":"31489802062929","imsi":"34116567506606","operatorId":3,"mscId":"5","fileId":"2"}],"draw":1,"limit":1000,"recordsFiltered":13419,"recordsTotal":13419}
这是我调用Ajax的方法,
var cdrReqParams = {};
cdrReqParams.draw = '1'; // need to change with the value from server in next server side ajax call
cdrReqParams.offset = 0; // need to change with the value from server in next server side ajax call
cdrReqParams.newRequest = '1';
cdrReqParams.totalRecords = '1'; // need to change with the value from server in next server side ajax call
cdrReqParams.lookInCol = 'aNumber';
cdrReqParams.lookInVal = anumber;
cdrReqParams.fromDate = startdate;
cdrReqParams.toDate = enddate;
var jsonStr = JSON.stringify(cdrReqParams);
console.log(jsonStr);
API.call("getBasicCallAnalysisData.json", 'POST', function(data) {
basicData = data.result; // Response from server
}, function(error) {
console.log(error);
}, jsonStr);
我在basicData中接收服务器响应,如何将json响应加载到我的数据表中,然后执行进一步的服务器端处理并从服务器更改所需的值(draw,offset,totalRecords),并在点击时执行另一个ajax调用第2页?
如果是这个我的API类:
var API = {
call:function(url,type,successcallback,errorCallback,data){
var data = (!!data) ? data : {};
var callback = (!!callback) ? callback : function(){};
$.ajax({
contentType : "application/json",
dataType: "json",
//crossDomain: true,
xhrFields: { withCredentials: true },
url: url,
data:data,
type:type,
success:successcallback,
error:errorCallback
});
}
}