This is self-explanatory:
while (...) {
var string='something that changes for each ajax request.';
$.ajax({'type': 'GET','dataType': 'json', 'url': 'get_data.php'}).done(processData);
}
function processData(data) {
// get string into here somehow.
}
As you can see, I need to get string into processData somehow. I can’t make a global variable because string is different for every ajax request. So, the question is, how do I bind string to my ajax request so that I can access it from processData?
I really don’t want to have to append string to the query and have the server return it, but if this is my only option, I have no choice.
Thanks in advance.
try in this way:
and no global variables were used 🙂