You have access to the variable if you make it by reference. All objects in Javascript are reference values, only eigenvalues ββare not (e.g. int, string, bool, etc.)
This way you can declare your flag as an object:
var flag = {};
$.ajax(
...
success: function()
{
console.log(flag)
}
)
Or make the success function have the necessary parameters:
var flag = true;
$.ajax(
...
success: function(flag)
{
console.log(flag)
}.bind(this, flag)
)
source
share