Link to home
Start Free TrialLog in
Avatar of tjgquicken
tjgquicken

asked on

WRONG_DOCUMENT_ERR: DOM Exception 4 in Safari/Chrome

I'm getting the following error in my jQuery/Javascript code when I run it on Webkit-based browsers: WRONG_DOCUMENT_ERR: DOM Exception 4. When I get the error, what I'm doing is loading an external XML document (that's XHTML compliant) and replacing one of the nodes in my original web page with a node from the XML document. This works fine in Firefox and Opera. Does anybody know how I get this to work? I posted the code below. Thanks.
$('.link').click( function() {
	// this.href must point to a well-formed XHTML file or the stylesheets won't work
	$.get(this.href, function(data, textStatus) {
		try {
			$('#main').replaceWith($('#main', data));
                        // there's a <div> node in the original web page with id="main" and a <div> node in the XML page with id="main"
		}
		catch(e) {
			alert(e);           // this gets triggered
		}
 
                // do more stuff
        }
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Albert Van Halen
Albert Van Halen
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial