title: Dynamically set, unset and clear Global Variables
body: <p>My need is to set a global variable after a ajax call. The global variable depends on the ajax's <code>success</code> data and I want to access the global variable in some other function.</p>
  
  <p>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.</p>
  
  <p>I tried with declaring var outside the function like <code>var globalvariable</code> and set the global variable value after ajax call like:</p>
  
  <pre><code>window.globalvariable = data;
  </code></pre>
  
  <p>but I am getting only empty results.</p>
  
  <p>What is the proper way to achieve this?</p>