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 !!