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