title: Access javascript variable inside ajax success
body: <pre><code>var flag = false; //True if checkbox is checked
  $.ajax({
      ... //type, url, beforeSend, I'm not able to access flag here
      success: function(){
          // I'm not able to access flag here
      }
  });
  </code></pre>
  <p>Inside ajax, if I try to access <code>flag</code> it says it is not defined. How can I use it inside ajax function?</p>
  <p>Any Idea?</p>
  <p>Both flag and ajax is body of a function. Nothing else is present inside that function.</p>