jquery Ajax Request Success also has response, but does not enter success

Source: Internet
Author: User
1. Status code return 200--indicates that the server responds to the client's request normally;
2. Through the httpwatcher of Firebug and IE, we can see that the server side returns normal data, and it is the data that conforms to the business logic, but the program simply does not enter the callback function success:function (data) {* *} but goes to error: function (data) {* *}.

The problem lies in:

1. Whether each data returned is a data type defined in datatype. If some of the data is not or even if a piece of data is not strictly defined by datatype, the program goes to Error:function () {* *},
You see if response is present CALLBACK,JSONP the request will take callback return should be callback, and the JSON request is not callback. To distinguish between the need to datatype is JSON or JSONP,
The data type that is returned must conform to the defined data type. That is, if the dataType you define is a JSON type, the returned data must be JSON, flat and otherwise the block of error will be executed.
2. Whether the requested domain and the current domain are the same domain, and if not the same domain, it is very likely to enter error:function () {* *}
3. It is also important to pay special attention to whether the JSON data returned is a strict JSON format.
4. It should also be a serious concern that when a list data is returned in the background (the data in the list is in JSON format), there is no dirty data that is not a strict JSON format.

jquery Ajax Request Success also has response, but does not enter success

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.