Following is my code for Ajax request:
for(some loop) {
var SOME-VARIABLE = value;
new Ajax.Request(SERVER-PATH + SOME-VARIABLE, {
asynchronous: true,
method: 'get',
onSuccess: function(response) {
//here I require SOME-VARIABLE
}
}
So, I am performing multiple ajax request in loop, Request is working perfect. But I want value of variable(SOME-VARIABLE) portion of request url in respective callback. As multiple-request are performed, in callback I could not get the the actual value of variable(it is replaced by subsequent loop iteration) Is there any way that I could access request-url-path in response-object of Onsuccess function.
Thank you.
Curly brackets do not have scope in javasrcipt, but functions do. So wrap in-brackets code by function: