I have a question about $.ajax in javascript:
If I have a function like this:
var jQueryFunction = function()
{
var array = new Array();
...
$.ajax ({
type: "GET",
async: false,
url: TPS_URL_1,
dataType: "jsonp",
jsonp: "callback",
jsonpCallback: "tpsHandler",
success: function(json)
{
array[0] = 1;
array[1] = 2;
}
});
}
After that when I check array value, it isn't set by anything and still null.
However I do like this:
var jQueryFunction = function()
{
var array = new Array();
array[0] = 1;
array[1] = 2;
...
$.ajax ({
...
});
}
It works fine.
So why I cannot set value for array inside $.ajax?