Jquery handles code for multiple AJAX requests at a time _jquery

Source: Internet
Author: User
Copy Code code as follows:

$ (document). Ready (function () {
$ (' #getsetgo '). Click (function () {
$.when ($.ajax ("page1.php"), $.ajax ("page2.php")). Done (function (A1, A2) {
$ (' #id1 '). html (a1[0]);
$ (' #id2 '). html (a2[0]);
});
});
});

When jquery 1.5 is released, it adds a method Jquery.when (). You can handle multiple AJAX requests at a time. See the jquery API documentation for more details.
Collection by Ancker

jquery Another way to handle multiple AJAX requests on the same page
Add a parameter
Copy Code code as follows:

$.post (
"Dosysthfile.aspx",
{
Type: ' 1 '
},
function (data, textstatus)
{
},
"JSON");
$.post (
"Dosysthfile.aspx",
{
Type: ' 2 '
},
function (data, textstatus)
{
},
"JSON");

In the DoSysthFile.aspx.cs file:
Copy Code code as follows:

if (!string. IsNullOrEmpty (request["type")) && (request["type"] = = "1"))
{
Do something
}
if (!string. IsNullOrEmpty (request["type")) && (request["type"] = = "2"))
{
Do something
}

This different Ajax can request the same page processing, do not need to create a new page for each AJAX request
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.