Reputation: 1674
I'm trying to make an XMLHttpRequest in the options page of an extension. In my options.js
file I simply have the following code :
if (window.XMLHttpRequest){
var xhr = new getXMLHttpRequest();
}
But I have this error in the console
Uncaught ReferenceError: getXMLHttpRequest is not defined
I saw here that getXMLHttpRequests are a problem for hosted apps, but in this case, it's a simple extension, so I don't understand.
Upvotes: 7
Views: 20620
Reputation: 1
You can use
function GetXmlHttpObject()
{
var objXMLHttp=null;
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return objXMLHttp;
}
Upvotes: -2
Reputation: 943556
To construct an XHR object you use new XMLHttpRequest();
.
getXMLHttpRequest
is not a standard function.
I saw here that getXMLHttpRequests are a problem…
The question at the other end of the link doesn't use a function with a name starting with get.
Upvotes: 5