Is it possible to retrieve variable set in onreadystatechange
function from outside the function?
--edit--
Regarding execution of functions:
If its possible i would like to execute ajaxFunction() with one click
and then popup() with next click, or
somehow wait for ajax function to end and then call for alert box
In pseudocode:
function ajaxFunction(){
//creating AJAX
...
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function (){
if(ajaxRequest.readyState == 4){
//success code
======>Here i want to set variable <=====
var MyVariable='MyContent';
}
}
//Retrieving page
....
}
function popup(){
ajaxFunction();
alert(MyVariable);
}