Use multiple URLs with $.getJSON

后端 未结 2 1459
小蘑菇
小蘑菇 2020-12-06 21:22

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         


        
2条回答
  •  鱼传尺愫
    2020-12-06 22:16

    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) {
    
    });
    

提交回复
热议问题