Is there a better to write the following?
I have two services that I need to call.
The data returned from the first service is needed to create the url for the second ajax call.
$.ajax({
url: 'http://service',
type: 'GET',
dataType: 'json',
timeout: 1000,
error: function(){
alert('Error loading json document');
},
success: function(json){
processJson(json.foo);
}
});
function processJson(url) {
$.ajax({
url: url,
type: 'GET',
dataType: 'json',
timeout: 1000,
error: function(){
alert('Error loading json document');
},
success: function(json){
displayJson(json.foo);
}
});
}