Warner Warner - 1 year ago 73
Ajax Question

how to get request data in ajax success callback method

I do ajax request in foreach and question is that how to get request data in success callback or how to match response data and request.
Thank you in advance!

Answer Source

Something like this:

var makeRequest = function(data){
    doAjaxRequest(data, function(dataFromServer){

What this does is for each element in array, the variable data is different because it refers to the local scope of the function makeRequest. This way, each callback refers to the proper data.