title: Javascript while loop callback
body: <pre><code>function jQueryFunction(url,callback)
  { 
      $.ajax
      ({
          type: "GET",
          async: false,
          url: url,
          dataType: "jsonp",
          jsonp: "callback",
          jsonpCallback: "tpsHandler",
          success: function(json)
          {
              return callback(json);
          }
      });  
  }
  
  function tmpFunction(callback) 
  {
      var jsonArray = new Array();
      var i = 0;
  
      while(true)
      {
          for(var j = 0; j &lt; url_array.length; j++)
          {
              jQueryFunction(url_array[j], function(json){
                  jsonArray[j] = json;
                  i++;
              });
          }
  
          if(i &gt;= url_array.length)
          {
              return callback(jsonArray);
          }
          else
          {
              alert(i);
          }
      }
  }
  </code></pre>
  
  <p>When I call tmpFunction the website keeps displaying "0" to me. Why is <code>i</code> always 0? Does tmpFunction never run the <code>for</code> loop?</p>