Examples abound of methods to initiate a web (HTTP) request in Javascript. But, when I initiate a web request and the server return a blank response, Firefox at least throws an error:
XML Parsing Error: no root element found Location: http://example.com/service Line Number 1, Column 1: 1 service:1:1
I am using a function similar to:
function RequestGET(url) {
var req = new XMLHttpRequest();
req.open("GET", url, true);
req.send();
}
In this particular case, the server has nothing to return and I expect that. So, how do I structure my client-side script to handle this response without throwing this error? Or, more generally, how can I handle a non-XML response properly?