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.
Here is the JavaScript code is question:
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.
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.
Here is the JavaScript code is question:
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.