Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 388
Carl Weis Avatar asked Aug 24 '11 17:08

Carl Weis


2 Answers

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);
like image 180
Trevor Veary Avatar answered Sep 20 '22 00:09

Trevor Veary


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);
    });
}
like image 21
Richard Andrew Lee Avatar answered Sep 21 '22 00:09

Richard Andrew Lee