开发者

SCRIPT 600 Error : Invalid target element for this operation

I have a php site that works fine in FireFox and Chrome, but breaks completly in IE.

Here is just one of the scripts that is throwing an error... SCRIPT600: Invalid target element for this operation.

function loadDeals() {
  开发者_如何学编程  $.get("modules/recommendations/viewrecommendations.php",{},function(response){
        document.getElementById("dealdata").innerHTML = response;
    });
}

It throws the error on the line that sets the innerHTML...Any ideas why this is happening?


IE has a problem replacing TBODY contents with innerHTML. The jQuery given above works; if you are not using jQuery, another solution is to have a <div id='helper' style='visibility:hidden'/> somewhere in the page - when the response arrives, put the value with a surrounding <table> tag into the hidden div, then use the DOM to remove the old contents from your visible tag and insert the elements from the hidden tag 1 by 1:

var a=document.getElementById("dealdata");

while(a.firstChild!=null)
  a.removeChild(a.firstChild);

var b=document.getElementById("helper");
b.innerHTML="<table>"+this.responseText+"</table>";
while(b.tagName!="TR") {
  if(b.tagName==null)
    b=b.nextSibling;
  else
    b=b.firstChild;
}
for(;b!=null;b=b.nextSibling)
  a.appendChild(b);


Try this: are you using jquery?

also looks like you have an extra set of brackets in there (i think between ,{},)

function loadDeals() {
    $.get("modules/recommendations/viewrecommendations.php",function(response){
        $("#dealdata").html(response);
    });
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜