jQuery Ajax Get XML Parsing Error: no element found Location: moz-nullprincipal

This error in Firefox

XML Parsing Error: no element found Location: moz-nullprincipal:{dd117028-da50-7b48-9a90-51f90c48ea9e} Line Number 1, Column 1

was seen on a xml get request using jQuery’s ajax function in this manner:

$.ajax({
        type: "GET",
        url: "myxml.xml", 
        dataType: "xml",
        success: myCompleteFunction,
        complete: mySuccessFunction,
        failure: function(data) {
            alert("Problem getting XML");
            }
    });

The fix was making sure the XML was valid and changing the dataType to html.

$.ajax({
        type: "GET",
        url: "myxml.xml", 
        dataType: "html",
        success: myCompleteFunction,
        complete: mySuccessFunction,
        failure: function(data) {
            alert("Problem getting XML");
            }
    });

By the way, the ajax request to get an xml file may also fail if the xml file is located on another domain. No fix if that is the case.

Posted in jquery. Tags: , . Permalink. Both comments and trackbacks are closed.

One Comment

  1. bird
    December 21, 2011 at 4:59 am | Permalink

    its helpful ..thanks for sharing