This article mainly introduces the type setting of Jquery.post usage, which can be consulted by a friend.
When using AJAX to get data, direct Data.foo can be obtained. and the lower version of jquery doesn't work. For example, before 1.4 code as follows: $.post ('/admin/userbookview.do ', {}, function (data) { Console.info ( Data); }); Print the data information, displaying a JSON-formatted string,: code as follows: {"Acceptis": null, "entity": null, " Refuseis ': null, ' result ': {' pageSize ':10, ' resultlist ': [{' Price ': 3, ' wctime ': null, ' note ': ' Integral 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 no type is set, the default returned data is the text type When we use data. To try to get the value inside, the return is undefined Two solutions: One: Use the Eval function to convert the JSON string to a JSON object code as follows: Var datas=eval ("(" +data+ ")"); II: Specify type types code as follows: $.post ('/admin/userbookview.do ', {}, function (data) { Console.info (data); }, "JSON"); High versions such as 1.8+ do not have this problem, returned as JSON objects