'XMLHttpRequest for XML to google app script doesn't work anymore

I have the following code that worked many months ago, for retrieving data from a Google Sheet and displaying it.

I originally wrote it to retrieve XML, but that didn't work with Internet Explorer, so I made it retrieve JSONP if we're on IE.

It continues to work in IE. However, it no longer works in Chrome or Firefox.

Upon network inspection, the XML is received like normal.

But in the javascript, xhttp.responseXML is null (with status 200).

The javascript:

function buildTable(xml)
{
    if(isIE())
        {
            var parser = new DOMParser();
            xml = parser.parseFromString(xml, "text/xml");
            //console.log(xml);
        }
    //Do stuff to display the data here.
}

if(!isIE())
        {
            var xhttp = new XMLHttpRequest();
            xhttp.onreadystatechange = function()
            {
                if (this.readyState == 4 && this.status == 200)
                {
                    console.log(xhttp.responseXML);
                    console.log(this.status)
                    buildTable(xhttp.responseXML);
                }
            }
        }

if(isIE())
    {
        console.log("Is IE.");
        $.ajax({
            url: "https://script.google.com/macros/s/KEYSTRING/exec?callback=buildTable",
            crossDomain: true,
            method: "GET",
            dataType: "jsonp",
            cache: false
        });
    }
    else
    {
        console.log("Not IE.");
        xhttp.open("GET", "https://script.google.com/macros/s/KEYSTRING/exec", true);
        xhttp.send();
    }

The (relevant) app script code:

function doGet(e)
{
  var xml = createXML_(getSheetData_())
  Logger.log("\n" + xml);

  if(e.queryString)
  {
    Logger.log("JSONP");
    xml = ContentService.createTextOutput("buildTable(" + JSON.stringify(xml) + ")");
    xml.setMimeType(ContentService.MimeType.JAVASCRIPT);
  }
  else
  {
    Logger.log("XML");
    xml = ContentService.createTextOutput(xml);
    xml.setMimeType(ContentService.MimeType.XML);
  }
  return xml;
}

If I hardcode isIE() to return true, using JSONP in every scenario, it works in all three browsers (IE, Chrome, and Firefox). But I'd like to know why XML no longer works.

Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source