AJAX on Internet Explorer: Setting innerHTML to xmlhttp.responseText fails
document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
//fails on IE: "Unknown runtime error". Line & character index is for the start of the word document. Works in Firefox.
document.getElementByI开发者_运维百科d("livesearch").innerHTML="Something special";
//works
alert(xmlhttp.responseText)
; // works on IE (done as a debug test)
Target of "livesearch" is a <div id="livesearch></div>
block
The content you're trying to insert has to be complete html in the strictest sense. One example I saw was: trying to insert <tr><td>data</td></tr>
gives that same runtime error because without <table>
actually in the code you're inserting, IE drops the <tr>
and <td>
tags, and you're trying to insert untagged text.
here was that example (user froufrou had posted this elsewhere): http://www.ericvasilik.com/2006/07/code-karma.html
don`t insert HTML code under non-block element.
<p>
<div id="livesearch></div>
</p>
<a href="xxx">
<div id="livesearch></div>
</a>
you should:
<div id="xxxxx">
<div id="livesearch></div>
</div>
精彩评论