Variable Lost In Ajax Request
I'm facing a strange behaviour when trying to pass a variable as parameter to a nested ajax request callback: $('form').on('submit',function(e){ $.ajaxSetup({ header:$(
Solution 1:
The first argument passed to the function in done
is the response from the AJAX request. It doesn't matter what you call the variable, that's what will be passed to that function.
You can capture the value in the closure however, simply give it another name and assign it to a local variable. Something like this:
done(function(response) {
var theId = id;
// "response" contains the response from the server.// "theId" contains the value of `id` from outside this function.
})
Post a Comment for "Variable Lost In Ajax Request"