I need to pass additional variables to the jQuery, ajax callback function.
For example, given:
while (K--)
{
$.get
(
"BaseURL" + K,
function (zData, K) {ProcessData (zData, K); }
);
}
function ProcessData (zData, K)
{
console.log (K);
}
ProcessData() will report 0 each time (or whatever the last K value is).
How can I guarantee that it ProcessData()works or can get the correct value of K?
Is there a way to do this without packaging $get()in a function?
source
share