I have a problem where I am not able to update a global variable from inside a callback function.
Here is my code:
// Set global variable.
var load_values_from_server = "initial value";
// Call our page that shows server load and put it into "results" variable.
microAjax("http://domain.com/show-server-load.php?" + randomnumber,
function (results) {
load_values_from_server = results;
});
// We want this to show the "results" from the callback function.
alert(load_values_from_server);
The problem is that the alert always shows "initial value" and never the "results" from the callback function.
What am I missing? Shouldn't global variables be global, even within a callback function?