It's not the first time you've been using AJAX to request data (and that's what it's all about), just yesterday I ran into a problem? The project needs to use Ajax to make the data request, so envelope the AJAX code copy to the project, front-end, background data processing finished, testing (thought can rest under), who knows the data successfully returned, the front-end did not complain, backstage is also true, obstinately did not perform success callback function, The heart is half cold.
The next step is to find the reason, look at the original code, Baidu, JSON format check, and finally found that the culprit is actually the jquery version of the cause of the problem.
jquery version: Jquery-1.9.0.min.js
As the jquery version increases, there is a strict requirement for the JSON format, and the original return message {success:true,id:1,result: "OK"} is no longer applicable in the high version, the following format is required
Copy Code code as follows:
{"Success": TRUE, "id": 1, "result": "OK"}
Summarize:
Key: Enclose in double quotes
Value:1. Numeric value, Boolean type does not use double quotes
2. Strings are enclosed in double quotes
Format: {success:true,id:1,result: ' OK '} does not pass
Format: {"Success": TRUE, "id": 1, "result": "OK"}