SCRIPT 600 Error: Invalid target element for this operation.

I have a php site that works fine in FireFox and Chrome, but is completely broken into IE.

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

function loadDeals() { $.get("modules/recommendations/viewrecommendations.php",{},function(response){ document.getElementById("dealdata").innerHTML = response; }); } 

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

+6
source share
2 answers

Try the following: are you using jquery?

also looks like this: you have an extra set of brackets (think between ,{}, )

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

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

 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); 
+12
source

Source: https://habr.com/ru/post/895783/


All Articles