我有一个发送ajax请求的循环。我想在我的ajax回调函数中包含循环索引:将动态变量附加到ajax回调函数
for (i=0;i<10;i++) {
$.ajax({
data: "index="+i
success: function (data) {
//I want to be able to see the variable (i) here
//since the request is async, it returns the last index on all
$("#div"+i).append(data);
}
})
}