title: Using interval in AJAX callback, variable not updating
body: <p>I am able to successfully retrieve data using the <code>get_data()</code> function inside a <code>setInterval</code>. However, when the AJAX function finds a new price, calling the <code>get_data()</code> function does not return the new price, but continues to return the price given on its first iteration (explained by the two console log lines)</p>
  
  <p>How can I have the price updated properly when calling <code>get_data()</code> inside an interval?</p>
  
  <pre><code>// Collect price data into array
  var interval = 1000;
  var arr = [];
  
  function price() {
      setInterval(function() {
          get_data(function(result) {
              arr.push(result);
              console.log('updated price: ' + arr[0]); // not updated correctly
          });
      }, 1000);
  
      function get_data(callback) {
          $.ajax({
              url: 'http://' + domain + '/site-options/',
              dataType: 'json',
              cache: fase,
              success: function(data) {
                  var price = data['gbp_price'];
                  var abs_change = data['gbp_abs_change'];
                  var p_change = data['gbp_change'];
                  var market_cap = data['gbp_market_cap'];
                  var today_max = data['gbp_today_max'];
                  var today_min = data['gbp_today_min'];
  
                  var obj = {
                      'price'      : price,
                      'abs_change' : abs_change,
                      'p_change'   : p_change,
                      'market_cap' : market_cap,
                      'max'        : today_max,
                      'min'        : today_min
                  };
  
                  console.log('price: ' + price); // updated correctly
  
                  if (callback) 
                      callback(obj);
              }
          });
      }
  }
  price();
  </code></pre>