W
will.hc.barker
Am trying to set up a very simple AJAX script for my website. The
javascript i have in an external file which reads as below.
This works perfectly in firefox but IE doesn't display anything at all.
No error messages, just a blank IE window. If you look at the IE source
this html is all there it just won't show it!
Any ideas
// JavaScript Document
function GetXmlHttpObject(handler)
{
var objXMLHttp=null;
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return objXMLHttp;
}
function getcounts(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="cgi-bin/countcomments.pl?blog_ids="
url=url+str
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
response = xmlHttp.responseXML.documentElement;
counts = response.getElementsByTagName('count');
for (i=0;i<=counts.length;i++)
{
id = response.getElementsByTagName('id').firstChild.data;
num = response.getElementsByTagName('num').firstChild.data;
idtofind = "commentcount" + id;
newhtml = " (" + num + ")";
document.getElementById(idtofind).innerHTML=newhtml;
}
}
}
javascript i have in an external file which reads as below.
This works perfectly in firefox but IE doesn't display anything at all.
No error messages, just a blank IE window. If you look at the IE source
this html is all there it just won't show it!
Any ideas
// JavaScript Document
function GetXmlHttpObject(handler)
{
var objXMLHttp=null;
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return objXMLHttp;
}
function getcounts(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="cgi-bin/countcomments.pl?blog_ids="
url=url+str
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
response = xmlHttp.responseXML.documentElement;
counts = response.getElementsByTagName('count');
for (i=0;i<=counts.length;i++)
{
id = response.getElementsByTagName('id').firstChild.data;
num = response.getElementsByTagName('num').firstChild.data;
idtofind = "commentcount" + id;
newhtml = " (" + num + ")";
document.getElementById(idtofind).innerHTML=newhtml;
}
}
}