对于我的 jQuery 应用程序,我想实现延迟加载。因此我创建了一个对象,其中包含我所有的 jqXHR 承诺。
当我现在将所有内容组合成一个声明时
var resultset = new Object();
resultset.one = $.getScript('http://......');
resultset.two = $.getScript('http://......');
$.when(resultset.one,resultset.two).then(
function(){ alert('success')},
function(){alert('failure')}
);
然后它总是进入错误状态。我不知道为什么,因为 js 调试器告诉,所有请求都很好(状态 200)。
JQ API 文档说明以下内容将起作用:
$.when($.ajax("/page1.php"), $.ajax("/page2.php"))
.then(myFunc, myFailure);
有任何想法吗?