Jquery load function throws "XML Parsing Error: not well-formed" error in firefox

Trying to load an xml file and getting the xml parsing error.

$("#analyticForm_description").load('https://192.168.23.10/SystemServices/main?system:run=html/indicators/templates/editApp-definition.xml&Id=1000205&palletId=testtt', function() { MD.ui.editPallets.editform_definition(); } );

Should not throw any error. Note the url provided is valid and accessible from a browser directly. The function is also being called. Somehow even after the error reported on console, page loads successfully.

Do not want to see any errors reported on console.

2 thoughts on “Jquery load function throws "XML Parsing Error: not well-formed" error in firefox”

  1. I was also facing a similar error and upon search i stumbled upon this post, after debugging code for a while i found out the reason.

    Error shown in console

    XML Parsing Error: undefined entity
    Location: path-to-file.html#link3
    Line Number 26, Column 29:
    

    Here is why i was getting this error

    I was dynamically generating url that i want to hit, and due to some typo i was getting undefined as the url which was used in making ajax calls resulting in this issue

    $.ajax({
        url: dynamic_url(undefined),
        type: "get",
        data: data,
        contentType: "text/xml",
        success: function (response) {
            //some code
        },
    });
    

    Posting this as it might help someone facing the same issue.

    Reply
  2. I think Firefox expects an Content-Type and Chrome ignores it.

    $.ajax({
        url : "https://192.168.23.10/SystemServices/main?system:run=html/indicators/templates/editApp-definition.xml&Id=1000205&palletId=testtt",
        contentType: "text/xml",
        success : function(response) {
            $("#analyticForm_description").html(response);
        }
    });
    

    or for the load method use ajaxSetup:

    Description: Set default values for future Ajax requests. Its use is
    not recommended.

    $.ajaxSetup({
      contentType: "text/xml"
    });
    
    $("#analyticForm_description").load('https://192.168.23.10/SystemServices/...', function() { 
      MD.ui.editPallets.editform_definition();
    });
    
    Reply

Leave a Comment