Drowning fish
I recently read jQuery's API documentation. When using jQuery's ajax, if dataType is specified as json, the success callback is not executed, but the error callback function is executed, which is extremely depressing. It can be executed later than version 1.2.6.
Then download several jquery versions, such as 1.3.2 and 1.4.0. If the specified ype is json, success callback cannot be executed. success callback can be executed only if the dataType is earlier than 1.3.
Finally go to the jquery site found the online api documentation to see the next, address: http://api.jquery.com/jQuery.ajax/, dataType found the following description
"Json": Evaluates the response as JSON and returns a JavaScript object. in jQuery 1.4 the JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. (See json.org for more information on proper JSON formatting .)
It turns out that jquery1.4 and later versions have very strict requirements on the json format. The success callback can be executed only when the format defined by the json.org website is met. Otherwise, errors will occur and the returned json data cannot be parsed. If it is more than 1.4, why cannot we execute the success callback when the ype specified in 1.3.2 is json?
No wonder, I returned an irregular string {success: true, id: 1} instead of a strict json format. It was changed to {"success": true, "id ": "1"} The success callback can be executed normally.
In JSON format, go to json.org to view details.
1) key name: enclosed in double quotation marks
2) string: enclosed in double quotation marks
3) numbers. Double quotation marks are not required for the boolean type.