Marketing digital. Making results.

Invalid Argument Error using ScriptTagProxy and IE6

As explained in my earlier post, i used Ext.data.ScriptTag proxy for some cross-domain AJAX data retrieval. Testing in IE6, I kept getting an “Invalid Argument” error in IE traced to this line in the code. A search on the Sencha forum turned up only this post, with no good solution posted. I traced the problem to thethis.head.removeChild lines, for some reason, IE6 chokes on it. The fix is quite simple, i overrode the function to use parentNode.removeChild:

Ext.override(Ext.data.ScriptTagProxy, {  	destroyTrans : function(trans, isLoaded){  	try  	{      	this.head.removeChild(document.getElementById(trans.scriptId));  	}  	catch(e)  	{  		//IE6 does not like removeChild() to be called directly from the parent element  		  document.getElementById(trans.scriptId).parentNode.removeChild(document.getElementById(trans.scriptId))  	}      clearTimeout(trans.timeoutId);      if(isLoaded){          window[trans.cb] = undefined;          try{              delete window[trans.cb];          }catch(e){}      }else{          // if hasn't been loaded, wait for load to remove it to prevent script error          window[trans.cb] = function(){              window[trans.cb] = undefined;              try{                  delete window[trans.cb];              }catch(e){}          };      }  }  	});