Getting Ajax to work



On my website <a href="htp://www.classiccat.net/">www.classiccat.net</
a> I am trying to implement some AJAX (I am rather new to Ajax). When
you press the "help" button on the menu on top some text is loaded by
an XMLHttpRequest and displayed at the top of the page. It works on my
PC (as localhost) in both IE 6.0 and the newest Firefox. However, when
I move the files to internet it doesn't work at all with Firefox. With
IE 6.0 it initially didn't work but after some experiments suddenly
worked (but I fear it won't work on other computers).

The help button is defined with 'href="javascript:help();"'. This
calls the function help() in the file <a href="htp://
www.classiccat.net/menu.js">menu.js</a>. The relevant code there is:

<code>
function LoadPage(url, callback)
{ if( typeof XMLHttpRequest == "undefined" )
XMLHttpRequest = function() {
try { return new ActiveXObject("Msxml2.XMLHTTP.6.0") } catch(e) {}
try { return new ActiveXObject("Msxml2.XMLHTTP.3.0") } catch(e) {}
try { return new ActiveXObject("Msxml2.XMLHTTP") } catch(e) {}
try { return new ActiveXObject("Microsoft.XMLHTTP") } catch(e) {}
throw new Error( "This browser does not support XMLHttpRequest." )
};
var request = new XMLHttpRequest();
request.open("POST", url, true); /* delaypage must be a global var
*/
request.onreadystatechange = function()
{ if (request.readyState == 4 && request.status == 200) /* done = 4,
ok = 200 */
{ if (request.responseText)
callback(request.responseText);
};
}
request.send(null);
}

function help()
{ LoadPage("help.htm",dynamo9);
}

function dynamo9(dytext)
{ var target=document.getElementById("helpdiva");
target.innerHTML = dytext;
}
</code>

Some tests with Firefox on internet showed that it runs the help() and
the LoadPage() functions but the dynamo9() function is never called.
Occassionally I get also the message that the help() function is not
found.

What am I doing wrong? Why doesn't this work?
.


Loading