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/xmlhttpreq开发者_StackOverflow中文版uest;1"]
.createInstance(Components.interfaces.nsIXMLHttpRequest);
Why is it better that I do this? What is the difference? Thanks in advance.
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.
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.
精彩评论