开发者

Multiple JSON objects

开发者 https://www.devze.com 2023-02-04 01:05 出处:网络
Hop开发者_如何学JAVAing someone can answer this one... Is it possible to load multiple JSON files using a single jQuery.ajax(); call? or would I need to create a call for each file?

Hop开发者_如何学JAVAing someone can answer this one... Is it possible to load multiple JSON files using a single jQuery.ajax(); call? or would I need to create a call for each file?

Your friendly neighbourhood, Smccullough


I believe you'll have to make multiple calls or concatenate the files at the server.


jQuery.ajax() does one http request at a time.

You could wrap it in a jquery function for loading the files. Pseudo-ish code:

jquery.fn = function loadFiles(data){
  $.ajax({
    url: data.file,
    dataType: 'json',
    success: callback
    ... and so on
  });

}

somewhere else in your code:

$(this).loadFiles({file:'file-one.ext'});
$(this).loadFiles({file:'file-two.ext'});
0

精彩评论

暂无评论...
验证码 换一张
取 消