Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.77 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Using setInterval in JavaScript without using an inline, anonymous function
  2. var updateNamespace = (function() {
  3.     var object = '#updates',
  4.     load = 'loader';
  5.  
  6.     return {
  7.         update: function() {
  8.             $(object).addClass(load).load('update.php', function(reponse, status, xhr) {
  9.                 if (status == 'error') {
  10.                     $(this).html('<li>Sorry but there was an error in loading the news & updates.</li>');
  11.                 }
  12.                 $(this).removeClass(load);
  13.             });
  14.         }
  15.     }
  16. })();
  17.  
  18. setInterval(updateNamespace.update(), 600000);
  19.        
  20. useless setInterval call (missing quotes around argument?)
  21.        
  22. setInterval(updateNamespace.update, 600000);
  23.        
  24. setInterval(updateNamespace.update(), 600000);
  25.        
  26. setInterval(undefined, 600000);