这篇文章需要删除
答
问题是它同时执行所有的GET,因为ASYNC它仍然在等待响应。一旦响应回来,它会使用I的设置值,即,可能是,无论我什么时候结束循环终止。你应该像这样递归函数:
return {
init: function(Args) {
_args = Args;
var container = _args[3].split(',');
jQuery(document).ready(function($) {
function makeCall(URL, counter) {
$.getJSON(getJSONURL, 'id=' + _args[0], function(res) {
$("#" + container[counter]).html(res.data);
});
}
for (i = 0; i < container.length; i++) {
var getJSONURL = 'http://www.thecashwidget.com/widget/frame.php?callback=?&c=' + _args[1] + '&r=' + _args[2];
makeCall(getJSONURL, i)
}
});
}
};
})();
我在工作,不能运行你的代码,但是我在失败的例子中返回的值是什么?我怀疑这不是你想象的那样......在回调中加入一些测试,找出真正发生的事情。 – wwwmarty
基于console.log(res.data)。我从URL路径中获得正确数量的响应。它只是不会在.html(res.data)的前端渲染。我添加了控制台日志,似乎我被困在迭代2。你有你的HTML页面
?我将开始一个jsBin –