Windows 10 will reach EOS (end of support) on October 14, 2025. For more information, see this article.

Hilfe durchsuchen

Vorsicht vor Support-Betrug: Wir fordern Sie niemals auf, eine Telefonnummer anzurufen, eine SMS an eine Telefonnummer zu senden oder persönliche Daten preiszugeben. Bitte melden Sie verdächtige Aktivitäten über die Funktion „Missbrauch melden“.

Weitere Informationen

XMLHttpRequest is undefined

  • 2 Antworten
  • 3 haben dieses Problem
  • 13 Aufrufe
  • Letzte Antwort von AMArostegui

more options

I'm writing a bootstrap Add-On for Thunderbird 24.3.0 on a Ubuntu 13.10 computer.

When trying to execute the following code snippet (taken for Mozilla Developer Network)

    var req = new XMLHttpRequest();
    req.open('GET', 'http://www.mozilla.org/', false); 
    req.send(null);
    if(req.status == 200)
        dump(req.responseText);

I get "ReferenceError: XMLHttpRequest is not defined" on the Error Console when trying to create the object.

This problem looks very similar to Firefox's:

https://support.mozilla.org/en-US/questions/987100

I'm writing a bootstrap Add-On for Thunderbird 24.3.0 on a Ubuntu 13.10 computer. When trying to execute the following code snippet (taken for Mozilla Developer Network) var req = new XMLHttpRequest(); req.open('GET', 'http://www.mozilla.org/', false); req.send(null); if(req.status == 200) dump(req.responseText); I get "ReferenceError: XMLHttpRequest is not defined" on the Error Console when trying to create the object. This problem looks very similar to Firefox's: https://support.mozilla.org/en-US/questions/987100

Ausgewählte Lösung

Hmm, could it be some change in the SDK?

It might be worth checking on this forum: http://forums.addons.mozilla.org/

Diese Antwort im Kontext lesen 👍 2

Alle Antworten (2)

more options

Ausgewählte Lösung

Hmm, could it be some change in the SDK?

It might be worth checking on this forum: http://forums.addons.mozilla.org/

more options

I think I found out the answer:

You cannot instantiate that way within a Javascript module. Should use

var req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]

                   .createInstance(Components.interfaces.nsIXMLHttpRequest);

instead.

Anyway, thanks for letting me know about the forum. Looks helpful.