Carl Weis
Carl Weis

Reputation: 7062

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?

Upvotes: 5

Views: 7607

Answers (2)

Trevor Veary
Trevor Veary

Reputation: 131

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);

Upvotes: 13

Richard Andrew Lee
Richard Andrew Lee

Reputation: 1177

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);
    });
}

Upvotes: 2

Related Questions