Jquery Ajax XMLHTTP Request success Problem _jquery

Source: Internet
Author: User

Today encountered a very strange problem, with a variety of tools to check can see the server side returned 200, the data is normal, but $.ajax always into the success, depressed Ah, looking on the Internet,

FAQ scenario:

1. Cross-domain;
2. $.ajax did not set the DataType, and the server side did not set the respon. ContentType
3. JSON structure error;

The first second was soon ruled out, to the third the definition of JSON: http://www.json.org/json-zh.html, revisit the definition of JSON:
Key-value pairs: The key is string, and the value can be in double quotes (string), numeric (number), True, False, NULL, objects (object), or arrays (array). These structures can be nested.

The type that was originally defined is
{issuccess:true,message: ' good '}
According to the definition of the key should be modified to
{' issuccess ': true, ' message ': ' Good '}
It is not possible to continue execution, as defined by the value:
{' issuccess ': true, ' message ': ' Good '}
Totally depressed, that's not good enough.
Down here. Look carefully at the specification of the JSON key value, the value to be defined as a string with double quotes, why is the double quotation mark, then the key, is not required? Into
{' issuccess ': true, ' message ': ' Good '}
It's straight through.
The format of JSON is different from the objects in JavaScript here, JSON requires the key, the value must be double quotes!!

Related Article

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.