Hello,
I have a problem where I am not able to update a global variable from inside a callback function.
Here is my code:
Code JavaScript:// Set global variable. var load_values_from_server = "initial value"; // Call our page that shows server load and put it into "results" variable. microAjax("[URL]http://domain.com/show-server-load.php[/URL]?" + 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?
Thanks!



Reply With Quote





Bookmarks