AJAX using DIV throws a runtime error
-
I have a div which is embedded inside a table. I can manually find the element using getByElementId("mytag"); I can even statically assign innerHTML, but my problem occurs when i try and assign it the responsetext from a XMLHTTP Object. If the DIV tag exists out the table on its own, then everything workds fine, its just when the div is embedded inside a table or even a form. What am i doing wrong, someone please help. I can document.write the responseText and its correct, I can even statically assign 'hello' to the innerHTML of my tag and all works. Any suggestions would be appreciated.
-
I have a div which is embedded inside a table. I can manually find the element using getByElementId("mytag"); I can even statically assign innerHTML, but my problem occurs when i try and assign it the responsetext from a XMLHTTP Object. If the DIV tag exists out the table on its own, then everything workds fine, its just when the div is embedded inside a table or even a form. What am i doing wrong, someone please help. I can document.write the responseText and its correct, I can even statically assign 'hello' to the innerHTML of my tag and all works. Any suggestions would be appreciated.
-
the Jscript code is: function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function stateChanged() { if (xmlHttp.readyState==4) { alert('got data'); //document.writeln(xmlHttp.responseText); var item = document.getElementById("cont"); //alert(item); var res = xmlHttp.responseText; item.innerHTML = res; //.innerHTML=; } } function loadArticle(id){ //alert('id is ' + id); xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="articles.aspx"; url=url+"?id="+id; xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } the htnl sits klike this
o.k assigning just "hello" to the innerHTML of cont works fine, but try and assign responseText and I getthe runtime error.
-
the Jscript code is: function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function stateChanged() { if (xmlHttp.readyState==4) { alert('got data'); //document.writeln(xmlHttp.responseText); var item = document.getElementById("cont"); //alert(item); var res = xmlHttp.responseText; item.innerHTML = res; //.innerHTML=; } } function loadArticle(id){ //alert('id is ' + id); xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="articles.aspx"; url=url+"?id="+id; xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } the htnl sits klike this
o.k assigning just "hello" to the innerHTML of cont works fine, but try and assign responseText and I getthe runtime error.
there is a < div > tag but it disappeared on posting. Its in the table cell.
-
I have a div which is embedded inside a table. I can manually find the element using getByElementId("mytag"); I can even statically assign innerHTML, but my problem occurs when i try and assign it the responsetext from a XMLHTTP Object. If the DIV tag exists out the table on its own, then everything workds fine, its just when the div is embedded inside a table or even a form. What am i doing wrong, someone please help. I can document.write the responseText and its correct, I can even statically assign 'hello' to the innerHTML of my tag and all works. Any suggestions would be appreciated.
Have you tried it in different browsers? I wonder if its a client-side error or a server-side error. You might also check to make sure you don't have a reserved name issue. Bart Edgerton http://www.ewebdev.net