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 the this.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){}
        };
    }
}
	});
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s