title: Variables set in response of jQuery post request
body: <p>I use the jQuery post requests a lot. I understand that when you are working within the response the variables have their own scope. Is there a good way to set variables in the response but have those variables available outside of the post? Like for other functions in JS.</p>
  
  <p>Here is a sample of what I am doing:</p>
  
  <pre><code> $.post('URL', { }, function(data) {
  
      var cData = $.parseJSON(data);
  
      $.each(cData, function(k, v) {
  
        var cID = v.id;  
  
    });
  </code></pre>
  
  <p>So what I do that I cannot access cID outside of the post request. Is there a way to make this work?</p>
  
  <p>Any help would be great.
  Thanks</p>
  
  <p>UPDATE:</p>
  
  <p>Here is a sample I just tested:</p>
  
  <pre><code>var savedCount;
  
  $.post('/app/actions/countsAction.php', { call: "getCountFullByID", countID: countID}, function(data) {
  
      savedCount = 1;
      alert(savedCount);
  
  });
  
  alert(savedCount);
  </code></pre>
  
  <p>I get 2 alerts when I run this. The first one is a 1 when the alert is fired off in the $.post and the second one is undefined.</p>