I am making a Firefox addon, and from a Firefox addon panel, I am trying to make an AJAX request to a site.
This is what I have so far:
package.json
{
//[...]
"permissions": {
"cross-domain-content": ["http://www.website.com", "https://www.website.com"]
}
}
main.js
var data = require("sdk/self").data;
var extension_panel = require("sdk/panel").Panel({
contentURL: data.url("menu.html"),
contentScriptFile: data.url("menu.js")
});
//[...]
menu.js
//[...]
$.ajax({
type: "GET",
url: "https://www.website.com/currentUser",
success: function(e){
$("#loading").hide();
},
error: function(e){
$("#loading").hide();
if (e.status == 401){
show_login();
return;
}
show_login();
$("#login-error").text("Couldn't check login status!").show();
}
});
//[...]
Every time I run this addon, it keeps giving the Couldn't check login status!
message.
When I log the error object, the status
is 404
, and statusText
is "error"
.
I think I have everything properly set up in package.json
, so why is the addon not allowing me to make the AJAX request?
EDIT
404
in this case doesn't mean that the URL doesn't exist. In the Chrome version of this very extension, everything works fine, so I know that the website hasn't changed on a last-minute basis.