Control the order of execution or the execution of all after [go] multiple AJAX requests

Source: Internet
Author: User

This article turns from: 71514822

First, when the order of execution is ensured:

1, request add async:false, so that all Ajax will be executed synchronously, the order of requests is the code sequence

2, $.when ($.ajax (
{Async:false,
Url:url1
}
), $.ajax (
{Async:false,
Url:url2
}
). Done (function () {

Alert ("Done");

}). Fail (function () {

Alert ("fail");

});

Second, ensure that all asynchronous AJAX requests are complete

1, ajax6 = $.ajax (
{
URL: "/home2/selectyjloginuser",
DataType: "JSON",
Type: "Post",
Success:function (pararesponse) {
}
});
AJAX7 = $.ajax (
{

URL: "/home2/selectyjzh",
DataType: "JSON",
Type: "Post",
Success:function (pararesponse) {
}
});

Make sure (ajax6, ajax7 two requests are complete
$.when (ajax6, ajax7). Done (function () {
The action
});
}

2, the second kind of the above can also be used

Control the order of execution or the execution of all after [go] multiple AJAX requests

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.