When using ajax to obtain data, data.foo can be obtained directly. However, lower versions of jquery will not work. For example, before 1.4
$ .post('/admin/UserBookView.do', {}, function(data) {
console.info(data);
});
Print data information and display is a string in json format, as follows:
{" acceptIs":null,"entity":null,"refuseIs":null,"result":{"pageSize":10,
"resultList":[{"PRICE":3,"WCTIME":null," NOTE":"Points exception","CKTIME":null,"CUSER":"admin",
"CTIME":"2013/12/30 17:03:16","PHONE":"13111050937", "ADDR":"Test Address","CUSERID":"1","SLTIME":null}],
"resultListArray":null,"titles":["ID","CTIME","STATE" "PRICE","NOTE"],"totalPage":1,"totalSize":4},
"source":null,"storageIs":null,"treeNodes":null}
If type is not set, the data returned by default is text type
When we use data. to try to get the value inside, undefined is returned
There are two solutions at this time :
1: Use the eval function to convert the json string into a json object
var datas=eval("(" data ")");
Two: Specify type
$.post('/admin/UserBookView.do', {}, function(data) {
console. info(data);
},"json");
Higher versions such as 1.8 do not have this problem and return json objects.