Jump to content

Ajax & Innerhtml


es131245

Recommended Posts

Im using AJAX to change divs innerHTML.FireFox after updating innerHTML 'understand' HTML in DIV but Chrome doent, it just shows HTML as text.Is the main idea is bad? Example function show(path){var content=document.getElementById('info');if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}else{xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');}xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){content.innerHTML=xmlhttp.responseText;content.innerText=xmlhttp.responseText;}}xmlhttp.open('GET','/production/'+path+'.htm',true);xmlhttp.send();}<a href="#" onclick="show('podsvetka');"><img src="source/podsvetka.jpg" alt="подсветка"><br />подсветка</a><div id="info"><img id="loading" src="/source/loading.gif" alt="Loading..." /></div>пример podsvetka.htm<table><tr><td>Podsvetka</td> <td>$1</td> <td>Green/red/blue/white</td></tr></table>

Link to comment
Share on other sites

This is the problem: content.innerText=xmlhttp.responseText;You're explicitly telling it to interpret it as text. Firefox doesn't understand the innerText property while Chrome does. Just delete that line.

Link to comment
Share on other sites

This is the problem: content.innerText=xmlhttp.responseText;You're explicitly telling it to interpret it as text. Firefox doesn't understand the innerText property while Chrome does. Just delete that line.
But some operas doent understand innerHTML, they used innerText instead
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...