In Jquery, Ajax does not execute the success callback function.

Source: Internet
Author: User

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 "}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.