开发者

Multiple JSON objects

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜