In this code, the ident and data variables are correct in the callback, but I don’t know how to pass in the right i for each loop iteration. I’ve tried reading up on functions and tried like 10 things, but alas, I must seek the wisdom of the stack.
function callback()
{
$(ident).html( data.fields[i].value );
$(ident).fadeTo('slow',1);
}
for(i=0;i<data.fields.length;i++)
{
ident='#'+data.rID+'_'+data.fields[i].field;
$(ident).fadeTo('slow',0,callback);
}
Change your “callback” function:
Then in your loop:
This “callback” implementation returns the function that you’ll pass to “fadeTo()”.