topical media & game development

talk show tell print

professional-ajax-03-Fallback-Patterns-Tr-Again-Later-Article.js / js



  
  var iFailed = 0;
  
  function downloadLinks() {
      var oXmlHttp = zXmlHttp.createRequest();
      
      if (iFailed < 10) {
          try {
              oXmlHttp.open("get", "AdditionalLinks.txt", true);
              oXmlHttp.onreadystatechange = function () {
                  if (oXmlHttp.readyState == 4) {
                      if (oXmlHttp.status == 200) {
                          var divAdditionalLinks = document.getElementById("divAdditionalLinks");
                          divAdditionalLinks.innerHTML = oXmlHttp.responseText;  
                          divAdditionalLinks.style.display = "block";          
                      } else {
                          throw new Error("An error occurred.");
                      }
                  }    
              }
              
              oXmlHttp.send(null);
          } catch (oException) {
              iFailed++;
              downloadLinks();
          }        
      }
  }
  
  window.onload = function () {
      if (zXmlHttp.isSupported()) {        
          downloadLinks();                  
      }
  };


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.