I am new to Ajax and jquery I have something like this:
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]
}
}
My problem is i is printed 10 times and then the codes which follows executes. Any help would be appreciated