It was not the first time I used ajax to request data (I always thought that was the case). I encountered a problem yesterday? Ajax is used in the project to request data. Therefore, the ajax code is copied to the project, and the frontend and backend data are processed and tested ), who knows that the data is returned successfully, the front-end does not report an error, and the back-end is also correct. The success callback function is not executed, and the heart is half-cooled.
The next step is to find the cause. Check the original code, Baidu and json format, and finally find that the cause of the problem is the Jquery version.
Jquery: jquery-1.9.0.min.js
As the Jquery version improves, there are strict requirements on the json format. The returned information similar to this format is {success: true, id: 1, result: "OK"} is no longer applicable in high versions. The following format is required:
Copy codeThe Code is as follows:
{"Success": true, "id": 1, "result": "OK "}
Summary:
Key: Double quotation marks are required.
Value: 1. Numeric value. Double quotation marks are not required for boolean type.
2. strings must be enclosed in double quotation marks.
Format: {success: true, id: 1, result: "OK"} failed
Format: {"success": true, "id": 1, "result": "OK "}