2013-12-07 19:15:29| Category: Web Front end | Tags:html | Report | Font size Subscription
$.ajax ({
Type: "Post",
URL: "index.php",
Data: "Id=" +uid,
DataType: "JSON",
Success:function () {
Alert (1);
},
Error:function () {
Alert (0);
}
});
In the Ajax method of jquery, after passing the parameters, the callback determines that there are two cases of success and error.
Sometimes, when the return value is not required, throw in the format of the template, set the dataType: "JSON", parameters;at this time, when the value of the Ajax is correct, 200 returned to the success of the error status of the special case.
You have not previously noticed the setup problem for the return value data type of the Ajax method. In the absence of callback parameters, it is generally not necessary to set the data type of the return value. If you set an error, you will usually be an error. This time, the direct cancellation DataType: "JSON",
Parameters can be.
The correct template for Ajax methods with no return value:
$.ajax ({
Type: "Post",
URL: "index.php",
Data: "Id=" +uid,
Success:function () {
Alert (1);
},
Error:function () {
Alert (0);
}
});
Again, if the callback parameter data format is not JSON, the same cannot be set dataType: "JSON" to avoid similar problems.
Transfer from http://wu110cheng.blog.163.com/blog/static/133349654201311771529542/
The Ajax method of jquery is set on the return value type when no return value