Im trying to send simple login/password parameters to my PHP file in my server from my simple Chrome extension. The code below gives me an “is not allowed by Access-Control-Allow-Origin”. What can I do to send simple parameters and receive the echo from the php?
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://mywebsite/api.php?u=admin&p=admin", true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
alert(xhr.responseText);
}
}
xhr.send();
What are some ways to contact my server and pass simple parameters and get responses from a google extension?
EDIT
“permissions”: [“contextMenus”,”http://mywebsite/”%5D,
You are doing a cross-origin XMLHttpRequest, so you need to set up some extra permissions for your extension. See this.
In your
manifest.jsonfile add:Remember to reload your extension after these changes.