My need is to set a global variable after a ajax call. The global variable depends on the ajax's success
data and I want to access the global variable in some other function.
The global variable should get cleared on a certain click event. If the ajax call made once again I want to set the global variable with a new value.
I tried with declaring var outside the function like var globalvariable
and set the global variable value after ajax call like:
window.globalvariable = data;
but I am getting only empty results.
What is the proper way to achieve this?