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