Jquer Ajax xmlhttp request succeeded. Why is jquerxmlhttp always in the error function?

Source: Internet
Author: User

Jquer Ajax xmlhttp request succeeded. Why is jquerxmlhttp always in the error function?

Reprinted from the http://www.cnblogs.com/sky_Great/archive/2013/01/18/2866861.html and Finishing:

Today, we encountered an extremely strange problem. We can see that the server returns 200 after checking with various tools. The data is also normal, but $. ajax is always inaccessible to success, so it's depressing to find it online,

Common Problem scenarios:
1. Cross-origin;
2. $. ajax does not set dataType, and does not set respon. ContentType on the server.
3. The Json structure is incorrect;

The first, second, was quickly ruled out. In the third place, the Json definition was revised: http://www.json.org/json-zh.html, And the jsondefinition was reviewed again:
Key-value pairs: The Key is string, and the value can be a string, number, true, false, null, or object enclosed in double quotation marks) or array ). These structures can be nested.

The previously defined type is
{IsSuccess: true, message: 'good '}
The key-based definition should be changed
{'Issuccess': true, 'message': 'good '}
If the execution fails, modify the value as follows:
{'Issuccess': true, 'message': "good "}
I'm totally depressed. This is not enough.
Later I put it down here and carefully read the Json key value specification. The value should be defined as a string with double quotation marks. Why is it double quotation marks? Do you need the key? Change
{"IsSuccess": true, "message": "good "}
The connection is successful.
The difference between the Json format and the objects in Javascript is here. Json requires a key and the value must be double quotation marks !!

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.