The Mask
The Mask

Reputation: 17427

Why not use XMLHttpRequest?

I'm using AJAX in my web application. However the documentation says to

instead of this:

var req = new XMLHttpRequest();

do this:

var req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
                      .createInstance(Components.interfaces.nsIXMLHttpRequest);

Why is it better that I do this? What is the difference? Thanks in advance.

Upvotes: 2

Views: 360

Answers (2)

Peter
Peter

Reputation: 27944

I think it has to do with chrome and non-chrome code, the

.createInstance(Components.interfaces.nsIXMLHttpRequest) 

works in both cases. You should test if this is still the case.

Upvotes: 0

fvu
fvu

Reputation: 32953

Guessing that your read this .... That remark is valid for XPCom modules, ie modules that live inside a Mozilla application. Not for web applications, so you should stick to the standard calls, or use some JS framework to shield you from differences between browsers.

Upvotes: 7

Related Questions