I am writing this code where I am sending a sequence of asynchronous post requests by using a loop. When the callback related with the post request is called I want to use the loop variable which I directly cannot use because of javascript scoping rules. The code is like this:
for(i=0;i<10;i++)
{
$.post(url,requestData,function(data,status,xhr){
// use variable i
}
I cannot directly use i due to scoping rules related to callbacks in javascript. So I want to pass 'i' as a parameter to the callback but the documentation says there can be only 3 parameters associated with this callback. Is there any way to pass additional parameter?