I am using PHP. I want finish the jQuery AJAX process, (finish process and after data back to the main page) .
Then do the next jQuery thing. Any ideas on how to do it?
$.ajax({
url: "page1.php",
dataType: "html",
type: 'POST',
data: "value=" + value,
success: function(data){
//some process
}
});//ajax1
$.ajax({
url: "page2.php",
dataType: "html",
type: 'POST',
data: "value=" + value,
success: function(data){
//some process
}
});//ajax2
$.ajax({
url: "page3.php",
dataType: "html",
type: 'POST',
data: "value=" + value,
success: function(data){
//some process
}
});//ajax3
// finish all the 3 ajax process, do the below code
$(".page").css('display','block');
If you are using jQuery 1.5 or better, you can use the heavenly
$.whenconstruct, which uses the$.Deferredconcept first implemented in that version of jQuery. You can run a function (or several functions) when all of several AJAX requests have completed.So your code would look like this: