开发者

Why not use XMLHttpRequest?

开发者 https://www.devze.com 2023-03-17 08:05 出处:网络
I\'m using AJAX in my web application. However the documentation says to instead of this: var req = new 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消