Addon works in Developer but not in Firefox browsers

After successful upload of my addon, I download and click browser-action icon. My app starts and determines I need to do a data install to Local Storage. I do this with my getJSON routine from my app root:
myURL = “/Resources/ApplicationData.json”
The json code (below) works in Developer but not in Firefox. I suspect it might be a security issue.
MY CODE:
function getJSON(myURL, callback) {
// Return “data” to the callback routine as an object.
$.ajax({
url: myURL,
dataType: “json”,
success: callback
})
}

MY MANIFEST:
{
“manifest_version”: 2,
“name”: “W3 Bookmarks”,
“version”: “21.9.11.95”,
“description”: “FireFox addon for capturing, storing, editing and searching bookmarks.”,
“author”: “John Leicht”,
“permissions”: [“storage”, “tabs”, “downloads”],
“background”: {“page”: “/modules/background.html”},
“browser_action”: {
“default_icon”: “/resources/icons/128x128.png”,
“default_title”: “W3 Bookmarks”
}
}

1 Like

Presumably that json file is part of your extension? If so, you can make it an absolute URL using https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime/getURL . You should be able to load that from your background page. If it still doesn’t work I’d suggest trying with fetch directly instead of using jquery.

Thank you!! I think this is the perfect answer. I will try getURL. If that doesn’t work, then Fetch. (I don’t know which is preferable). Why doesn’t Developer version behave the same as production (Firefox/AMO)??

because most likely the installation method of the extension isn’t the same.

Also, there’s probably an error in the add-on toolbox that outlines what exactly went wrong, or at least the $.ajax error handler will have some information. See also https://extensionworkshop.com/documentation/develop/debugging/

Thanx again! These little tips greatly help a novice.