title: Why are parameters not sent to a function in setInterval() all the time?
body: <p>I have a page that automatically refreshes content via Ajax. I want this to be subtle so I do not want to display my loading gif during automatic page refreshed. So I did something like this with my getPosts function (unnecessary code cut out for succinctness)</p>
  
  <pre><code>function getPosts(image) 
              {
                  //loading icon while getPosts
                  if (image)
                  {
                      $("#postcontainer").bind("ajaxStart", function(){
                          $(this).html("&lt;center&gt;&lt;img src='ajax-loader.gif' /&gt;&lt;/center&gt;");
                  });
                  } //... ajax call, etc. don't worry about syntax errors, they aren't in real code
  </code></pre>
  
  <p>I know the center tag is deprecated, just a shameless shortcut.
  And then I will set the interval like <code>setInterval(function() { getPosts(false); }, 10000);</code>
  Therefore my automated calls will not trigger the image to display
  All my manual refreshes will then call it like this <code>getPosts(true);</code></p>
  
  <p>You can (probably) see the bug in action at <a href="http://www.ethoma.com/testhome.php" rel="nofollow">my personal site</a></p>
  
  <p>The problem is, the setInterval function seems to use the image bool from the latest function call. So it does not display the image at first during automated calls, but after I click a manual refresh, it starts showing the image during each call.</p>
  
  <p>How can I combat this?</p>
  
  <p>Thanks for anyone who views/posts this topic! I hope this question becomes a good reference to others.</p>