Problem of type setting for jquery.post usage

Source: Internet
Author: User
Tags eval json

  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  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.