I have a few lines of code:
var url = \'http://api.spitcast.com/api/spot/forecast/1/\';
var url_wind = \'http://api.spitcast.com/api/county/wind/orange-count
You'll need two calls, but you can use $.when
to tie them to the same done()
handler :
var url = 'http://api.spitcast.com/api/spot/forecast/1/';
var url_wind = 'http://api.spitcast.com/api/county/wind/orange-county/';
$.when(
$.getJSON(url),
$.getJSON(url_wind)
).done(function(result1, result2) {
});
you cannot, use two separate calls:
$.getJSON(url, function (data) {
$.getJSON(url_wind, function (data2) {
//do stuff with 'data' and 'data2'
});
});
Example above will execute the second call (to url_wind) when the first call (to url) has finished. To execute the two calls in parallel, use $.when() like this:
$.when($.getJSON(url), $.getJSON(url_wind)).done(function(data1, data2) {
//do stuff with 'data' and 'data2'
});