From: Elizabeth.Lattanzio on 3 Jan 2008 10:01 Hi all, So I've been searching the various forums out there for an answer to this problem, but their seem to be multiple versions. I am using the getElementById function in my ajax and though it works fine in firefox, it returns the following error in Internet Explorer: 'document.getElementById(...)' is null or not an object. Now one post said its because I.E. is not case sensitive, so I made it all lower case and nothing. Don't know what else the problem might be, but here is the code: //// function getMenu(){ xmlHTTP2=GetXmlHttpObject(); if (xmlHTTP==null){ alert ("Your browser does not support AJAX!"); return; } url2= "GEPmenu.html"; xmlHTTP2.onreadystatechange=menuPrint; xmlHTTP2.open("GET",url2,true); xmlHTTP2.send(null); } function menuPrint(){ if (xmlHTTP2.readyState == 4) { if (xmlHTTP2.status == 200) { xmldoc2 = xmlHTTP2.responseText; document.getElementById("menutable").innerHTML = xmldoc2; ///This is the problem line } else { alert('There was a problem with the request.'); } } } /// ///This should be changing the contents of the following table in my html (I thought maybe it was a table quirk, but also tried it with a div... No go.): <table width="170" border="1" cellpadding="5" cellspacing="0" bordercolor="#CCCCCC" bgcolor="#CC3333" id = "menutable"> </table> Any answers? Thanks, Liz
From: David Dorward on 3 Jan 2008 10:06 On Jan 3, 3:01 pm, Elizabeth.Lattan...(a)gmail.com wrote: > document.getElementById("menutable").innerHTML = xmldoc2; ///This > is the problem line > <table width="170" border="1" > cellpadding="5" cellspacing="0" > bordercolor="#CCCCCC" bgcolor="#CC3333" id = > "menutable"> Live URIs are usually easier to debug then snippits of code. The problem might be related to IE having issues with editing the innerHTML of table elements (avoid using innerHTML to modify the contents of tables). You also have a lot of presentational markup there, which should be moved into a stylesheet. -- David Dorward http://dorward.me.uk/ http://blog.dorward.me.uk/
From: Doug Gunnoe on 3 Jan 2008 10:41 > 'document.getElementById(...)' is null or not an object. Liz, I tried in IE 6 had no problem with getElementById("menutable"), except when I tried to modify innerHTML, but I got a different error than you so it was probably the way I was doing it. > function getMenu(){ > xmlHTTP2=GetXmlHttpObject(); > if (xmlHTTP==null){ > alert ("Your browser does not support AJAX!"); > return; > } > url2= "GEPmenu.html"; > xmlHTTP2.onreadystatechange=menuPrint; > xmlHTTP2.open("GET",url2,true); > xmlHTTP2.send(null);} > > function menuPrint(){ Do you realize that you have a function inside a function here? Good luck, Doug
From: Doug Gunnoe on 3 Jan 2008 10:43 On Jan 3, 9:41 am, Doug Gunnoe <douggun...(a)gmail.com> wrote: > > 'document.getElementById(...)' is null or not an object. > > Liz, > > I tried in IE 6 had no problem with getElementById("menutable"), > except when I tried to modify innerHTML, but I got a different error > than you so it was probably the way I was doing it. > > > function getMenu(){ > > xmlHTTP2=GetXmlHttpObject(); > > if (xmlHTTP==null){ > > alert ("Your browser does not support AJAX!"); > > return; > > } > > url2= "GEPmenu.html"; > > xmlHTTP2.onreadystatechange=menuPrint; > > xmlHTTP2.open("GET",url2,true); > > xmlHTTP2.send(null);} > > > function menuPrint(){ > > Do you realize that you have a function inside a function here? > > Good luck, > > Doug Actually you don't. I did not see the last '}'
|
Pages: 1 Prev: Safari and Window.onload timing Next: DOM Scripting Not Working In IE |