I need to pass extra variables to a 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 every time (or whatever the last value of K was).
How do I ensure that ProcessData()
fires with, or can get, the correct value of K?
Is there any way to do this without wrapping the $get()
in a function?