i need to make two different ajax calls and pass both the json data to another function. how can i do it using below ajax call format?
$.ajax({
url:'',
type:'GET',
dataType: 'json',
success: callme
});
$.ajax({
url:'',
type:'GET',
dataType: 'json',
success: callme
});
function callme(JSON1,JSON2){
}
This is the perfect use case for
$.when(assuming you’re using jQuery):The
donecallback will only be called when both requests have completed successfully; thefailcallback will be called if any request fails.