我想正在做是在一个特定的顺序,让我进一步解释使用一些code中的Ajax调用。
I want the ajax calls that are being made to be in a particular order, Let me explain further using some code.
var feed_urls = [
'URL_1',
'URL_2',
'URL_3',
...
...
'URL_N',
];
我正在使用jQuery的的getJSON
方法,像这样的Ajax调用
I am making ajax calls using jquery's getJSON
method like so
$.each(feed_urls,function(index,value){
$.getJSON(value, function(data) {
$.each(data.feed.entry,function(i,val){
LIST.push(val.content.src);
});
});
});
我现在面临的问题是,因为Ajax调用是异步的列表的内容
并不总是以相同的顺序。反正是有解决这个问题?
The problem I am facing is that since ajax calls are asynchronous the content of LIST
is not always in the same order. Is there anyway to solve this ?
将 URL_1
然后按 URL_2
的AJAX调用的preferable顺序,然后按 URL_3
等等,直到 URL_N
The preferable order of ajax calls would be URL_1
followed by URL_2
followed by URL_3
and so on till URL_N
使用ajaxSetup()与异步:假的,它会重新:
use ajaxSetup() with async :false, in it re:
$.ajaxSetup(
{
data: "{}",
async false,
..whatever else you need