According to the Firefox Content Script ,the XMLHttpRequset can be used.
I have tried both XMLHttpRequest and Api Fectch.It only responses with error message. I already disable CORS on the server.It still dosen't work.
I run Django local server on the computer.
This is the code:
function getWord(word){
var req = new XMLHttpRequest();
req.open("GET", "http://127.0.0.1:8000/api/${word}/",true);
req.onload = function(){
console.log("done");
}
req.onerror = function(){
console.log("error : ",this.error);
}
req.send();
Console error:
error { target: XMLHttpRequest, isTrusted: true, lengthComputable: false, loaded: 0, total: 0, currentTarget: XMLHttpRequest, eventPhase: 2, bubbles: false, cancelable: false, defaultPrevented: false, … }
It work on other files(Not extension).
The problem is that I forgot to set the permission in the manifest.json.
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/permissions
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.