Asynchronous JavaScript

    Date: 11/11/05 (WebDesign)    Keywords: html, xml, java, microsoft

    I'm building a page and plan on using some Asynchronous JavaScript (AJAX without the XML basically). Anywho, the problem is, it just doesn't seem to work at all.

    I've slowly worked my way through the code and I can't figure out for the life of me why it's just not working. I've tried using alert() to show my progress through the script, but it won't even show the first alert() which I had put before the function even creates it's first variable. I remove the code and leave only the alert() and it pops up.



    function ajaxLauncher()
    {
      var args = ajaxLauncher.arguments;
      var httpRequest = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHTTPRequest();
    
      switch (args[0])
      {
        case "begin_exe"
        {
          alert("Working!");
          setContent();
          ajaxLauncher("show_content", "mainContent[0]", "content");
          break;
        }
        case "show_content"
        {
          if (httpRequest)
          {
            httpRequest.onreadystatechange = function()
            {
              if (httpRequest.readyState == 4 && httpRequest.Status == 200)
              {
                container = document.getElementByID(args[2]);
                container.innerHTML = httpRequest.responseText;
              }
            }
            httpRequest.open("GET", args[1], true);
            httpRequest.send(null);
          }
          break;
        }
      }
    }
    
    function setContent()
    {
      mainContent = new Array();
        mainContent[0] = "index2.html";
    }
    



    I'm calling it on my page's onload event.

    Any help would be very much appreciated.

    x-posted to Tek-Tips.

    Source: http://www.livejournal.com/community/webdesign/1014912.html

« Getting to know your Flash... || Not online web portfolio »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home