XMLHttpRequest in Firefox Extension

后端 未结 3 1595
梦如初夏
梦如初夏 2020-12-06 17:43

I am writing a FireFox-Extension and want to load Data from Server. But when I try to initialize the XMLHttpRequest with:

var request = new XMLHttpRequest();         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 18:24

    For using XMLHttpRequest constructor you should add the XPCOM component constructor:

    const XMLHttpRequest  = Components.Constructor("@mozilla.org/xmlextras/xmlhttprequest;1", "nsIXMLHttpRequest");
    

    and after:

    // some code
    var req = new XMLHttpRequest();
    // some code
    

    More info on MDN

提交回复
热议问题