Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XMLHttpRequest in Firefox Extension

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();

The error console says:

ReferenceError: XMLHttpRequest is not defined

Do I have to include something or why the XMLTttpRequest is not recognized?

like image 932
SteMa Avatar asked Jan 02 '12 12:01

SteMa


People also ask

What is new XMLHttpRequest ()?

XMLHttpRequest (XHR) objects are used to interact with servers. You can retrieve data from a URL without having to do a full page refresh. This enables a Web page to update just part of a page without disrupting what the user is doing. XMLHttpRequest is used heavily in AJAX programming.

Why is it called XMLHttpRequest?

The Outlook team was transferring XML from server to client, so the ActiveX control was named to reflect its primary use at the time. It was included as part of the MSXML parser.


1 Answers

The Add-on SDK (that you are using indirectly via the Add-on Builder) provides a request package that is essentially a wrapper around XMLHttpRequest, you should use it. From what I understand, you aren't given direct XMLHttpRequest access to prevent issues if the add-on is uninstalled/disabled while a request is being performed.

like image 90
Wladimir Palant Avatar answered Sep 20 '22 15:09

Wladimir Palant