我是Ajax和jquery的新手 我有这样的事情:
var a=0;
var resp= [ Some array ]
for(i=0;i<10;i++)
{
console.log(response[i])
console.log(i) //this gets executed 10 times after which the following code executes
// make ajax call
var temp= function(){
var deferred = $.Deferred();
//set some value
a=5;
return deferred.promise();
}
temp.done(function(){
var myvar = a + resp[i]
}
}
我的问题是我被打印10次然后执行下面的代码。任何帮助将不胜感激