Possible Duplicate:
Javascript closure inside loops - simple practical example
for (i=0; i<N; i++) {
$.get("script"+ i +".jsp", function() {
//I want to use i here
//but by the time the ajax request comes back i==N, but I want the old i
})
}
So I got this code and I was wondering if there is a better way to do it than the one from my response. This is not about jquery ajax calls, I'm aware there are ways to pass "i" through the event object, I want a general solution better than the one I came up with.