$(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.