Ajax request succeeded, but error callback was performed

Source: Internet
Author: User
Tags parse error

problem : Through jquery encapsulation Ajax request for File upload operation, the back end has returned upload file success, the front-end reference also no problem, the browser does not have any error, but always enter the error callback, the first big.


cause of the cause:

1.a link problem

If a link has href,href= "" will refresh the page, before refreshing the page will enter the action, so will invoke Ajax to get the submission of data, but before returning, the page will be refreshed operation, as long as the change to href= "#", add a click event on OK.

2.dataType

If you specify datatype as JSON when you perform AJAX, first check the jquery version, only a version less than 1.3 can perform the success callback, and the following version is very demanding in JSON format

"JSON": evaluates the response as JSON and returns a JavaScript object. In JQuery 1.4 The JSON data are parsed in a strict manner; Any Malformedjson are rejected and a parse error is thrown. (Information on proper JSON formatting.)

The JSON format should meet the following requirements :

Key Name: Double quote

Strings: Double Quotes

Numbers, Boolean types: no double quotes required


So far, only two of them have been encountered, there should be other reasons, welcome to append


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.