Created
April 21, 2016 16:53
-
-
Save csessig86/f049bb2d2f076e693d2dc85ca238b34a to your computer and use it in GitHub Desktop.
Making two AJAX calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Holds data for each AJAX call | |
var global_data = {}; | |
var global_data_two = {}; | |
// Do the merge of the data here | |
function mergeData() { | |
console.log('merge data here'); | |
} | |
// Second AJAX call | |
function secondAjaxCall() { | |
$.ajax({ | |
type: "GET", | |
dataType: "json", | |
url: 'https://datagetter.herokuapp.com/arrests.json', | |
success: function(data){ | |
global_data_two = data; | |
}, | |
complete: function() { | |
console.log('second AJAX call'); | |
console.log(global_data); | |
console.log(global_data_two); | |
mergeData(); | |
} | |
}); | |
} | |
// First AJAX call | |
$.ajax({ | |
type: "GET", | |
dataType: "json", | |
url: 'https://datagetter.herokuapp.com/arrests.json', | |
success: function(data){ | |
global_data = data; | |
}, | |
complete: function() { | |
console.log('first AJAX call'); | |
console.log(global_data); | |
secondAjaxCall(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment