I have the following scenario in my javascript:
Bit late to answer, but
Much better way is to use promises as the way they designed to be used
Pseudo implementation
var promise = $.ajax({
url: url,
data: data
}).done(function (data) {
var result = process(data);
return $.ajax({
url: url,
data: result
});
}).done(function (data) {
// data is the result of second ajax call
});