title: Keep a javascript variable after an ajax call
body: <p>I'm new in javascript and jQuery. 
  I'm using ajax calls to get data from my server. The fact is, I'm losing my javascript variables after the call .. 
  Here is what I did : the variable is define outside any function and treat in an other function. </p>
  
  <pre><code>var a = 0;
  function myfunction(url){
  $.ajax({
          url: url,
          timeout: 20000,
          success: function(data){
                    // Do some stuff
                    // The a variable is now undefined
                  },
          error: function(){
                    // Do some stuff
                  }
         });
  }
  </code></pre>
  
  <p>Everything is working fine, the only thing is that I need to keep my variables ... but it looks like it's gone ..</p>
  
  <p>Does anyone know why? </p>
  
  <p>Thanks</p>