Ajax request State 200, but go to the function of error

Source: Internet
Author: User

has been nearly one months without the formal use of Ajax request code, to participate in the work, this is the first use, feel a little rusty, but the basic code is still remember, write it is not laborious, but because of this, the problem comes, due to lack of experience, the cause of the problem is not that, I mistakenly think that is that, So the commissioning took a long time.

Part of the code for AJAX is as follows:

$.ajax ({
URL: ' http://XXXXX/practice/pj2/Merchant.class.php ',
Type: "POST",
Data:{tel:tel},
DataType: ' JSON ',
Success:function (msg) {
Alert (' Send success, please check! 1 ');
alert (msg.name);
},
Error:function () {
Alert (' request failed! ‘);
}

}); I always thought it was my code problem, later through the query, the original is the JS cross-domain problem, that is, the URL part: url: ' http://XXXXX/practice/pj2/Merchant.class.php ', Address to the address of the file itself under the same domain name, so the file and the AJAX request files are rewritten to a local test, the success of the experiment, has never been JS cross-domain problems, and now understand the problem, to solve the problem there is a solution ... Experience is important!

Ajax request State 200, but go to the function of error

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.