JSON returned using the jquery post submission data is a string that cannot be parsed as a JSON object

Source: Internet
Author: User

Just started to intervene in programming, a lot of things can not be done on their own, just started to make a lot of mistakes.

Use the CSDN blog as your own notes.

Today, using JQuery's post to submit data, I need to use the data he returned,

[JavaScript] view Plaincopyprint?

  1. jquery.post (url+'/usertag/option/deltag/index/'+index,

  2. function (JSON) {

  3. Console.log (JSON);

  4. Console.log (Json.data);

  5. });

When I look at the input data in the console, I get the JSON, but Json.data is undefined.

{"Status": 1, "info": "\u5220\u9664\u6210\u529f", "Data": "1"}

Undefined

Just start getting started, so it feels right to look at it. Why not call his attributes?

Google search for a bit, the results only found that I got a JSON string ... is not an object at all, how to invoke its properties?

So you need to change it, the workaround, declares that the return value is of type JSON because there is no write return to the "JSON" type, which returns a string type.

[JavaScript] view Plaincopyprint?

  1. jquery.post (url+'/usertag/option/deltag/index/'+index,

  2. function (JSON) {

  3. Console.log (JSON);

  4. Console.log (Json.data);

  5. },' json ');

OK, this is right, the front of the object several large characters in front, but also not justified.

Hey, beginner programming is to eat a bit more bugs, or there will be no progress.


JSON returned using the jquery post submission data is a string that cannot be parsed as a JSON object

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.