WRONG_DOCUMENT_ERR: DOM Exception 4 in Safari/Chrome

Posted on 2009-02-08
Last Modified: 2013-11-18
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

Question by:tjgquicken
    1 Comment
    LVL 19

    Accepted Solution


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
    PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
    The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
    The viewer will learn how to dynamically set the form action using jQuery.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now