Jquery code to handle multiple ajax requests at one time_jquery
$(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]);
});
} );
});
After the release of jquery 1.5, a new method jQuery.when(). can handle multiple ajax requests at one time. See jquery api documentation for more details.
Collection by Ancker
Another way jquery handles multiple ajax requests on the same page
Add a parameter
$.post(
"doSysthFile.aspx",
{
type: '1 '
},
function(data, textStatus)
{
},
"json");
$.post(
"doSysthFile.aspx",
{
type: '2'
},
function(data, textStatus)
{
},
"json");
In the doSysthFile.aspx.cs file:
if (( !string.IsNullOrEmpty(Request["type"])) && (Request["type"] == "1"))
{
//do something
}
if ((! string.IsNullOrEmpty(Request["type"])) && (Request["type"] == "2"))
{
//do something
}
This different ajax request can be processed by the same page, and there is no need to create a new page for each ajax request.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to extend the expiration time of Ajax requests? When making network requests, we often encounter situations where we need to process large amounts of data or complex calculations, which may cause the request to time out and fail to return data normally. In order to solve this problem, we can ensure that the request can be completed successfully by extending the expiration time of the Ajax request. The following will introduce some methods and specific code examples to extend the expiration time of Ajax requests. When making an Ajax request using the timeout attribute, you can set the timeout attribute to

AJAX requests have no fixed expiration time: "Asynchronous JavaScript and XML" is a technology for sending asynchronous requests on web pages, which uses JavaScript to send requests to the server and receive responses without refreshing the entire page.

In the Yii framework, controllers play an important role in processing requests. In addition to handling regular page requests, controllers can also be used to handle Ajax requests. This article will introduce how to handle Ajax requests in the Yii framework and provide code examples. In the Yii framework, processing Ajax requests can be carried out through the following steps: The first step is to create a controller (Controller) class. You can inherit the basic controller class yiiwebCo provided by the Yii framework

Practical guide: Which Ajax request libraries are suitable for your project? With the continuous development of front-end development, Ajax has become an indispensable part of web development. Choosing an Ajax request library suitable for the project is crucial to improving development efficiency and optimizing user experience. This article will introduce several commonly used Ajax request libraries to help readers choose the tool suitable for their own projects. jQueryAjax There is no denying that jQuery is one of the most popular JavaScript libraries out there. It provides a rich

Development essentials: Explore what are the commonly used Ajax request libraries? In modern front-end development, using Ajax for asynchronous requests has become a standard feature, and choosing an appropriate Ajax request library can allow us to process network requests more efficiently, improving development efficiency and user experience. This article will explore some commonly used Ajax request libraries to help developers choose the tools suitable for their projects. jQueryAjax: As one of the most popular JavaScript libraries, jQuery provides powerful Ajax request functions.

Can the expiration time of Ajax requests be customized? In web development, we often use Ajax to implement asynchronous requests to dynamically load data in the page. When making Ajax requests, sometimes we need to control the timeout of the request, that is, set a time limit, and process it if no response is received within the specified time. So, can the expiration time of Ajax requests be customized? This article will introduce this problem in detail and provide specific code examples. Using jQuery's Ajax function

Under what circumstances will an Ajax request expire? With the development of Web applications, Ajax (Asynchronous JavaScript and XML) technology has become an essential part of Web development. Through Ajax, we can obtain data from the server and dynamically update the content of the web page without refreshing the entire page. However, when using Ajax to send requests, sometimes you encounter request expiration. So, under what circumstances will an Ajax request expire?

How to set the expiration time of Ajax request? Need specific code examples With the development of Internet applications, Ajax has become an indispensable part of Web development. When sending an Ajax request, sometimes we need to limit the expiration time of the request to prevent the request from being too long, resulting in poor user experience or browser freezes. This article will introduce in detail how to set the expiration time of Ajax requests and give specific code examples. Setting the expiration time of Ajax requests mainly requires XMLHttpRequest
