rkosegi
rkosegi

Reputation: 14618

XMLHttpRequest responseXML is null on firefox 10

I have XMLHttpRequest inside firefox addon which like this :

httpRequest = new XMLHttpRequest();
httpRequest.open("POST", baseUrl + "check.php?uid=" + username, true);
httpRequest.responseType = "document";
httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");      
httpRequest.setRequestHeader("Content-length", dataString.length);
httpRequest.setRequestHeader("Connection", "close");
httpRequest.onload = infoReceived;
httpRequest.send(dataString);

I works just fine on recent version of firefox (14.0.1).

However, on Firefox ESR 10, httpRequest.responseXML is null inside handler procedure (infoReceived)

Any hint, please?

I check MDN docs but there is no note about incompatibility in ESR 10 version.

Upvotes: 2

Views: 1562

Answers (1)

rkosegi
rkosegi

Reputation: 14618

OK, I figure it out.

Before (inside handler function):

var response = httpRequest.responseXML;

After (inside handler function):

var parser = new DOMParser();
var response = parser.parseFromString(httpRequest.responseText, "text/html");

Before (main function) :

httpRequest.responseType = "document";

After (main function) :

//httpRequest.responseType = "document";

I also found correct info inside MDN doc:

enter image description here

Upvotes: 2

Related Questions