I\'m porting one of my Firefox extensions to Chrome, and I\'m running into a little problem with an AJAX query. The following code works fine in the FF extension, but fails
Check your manifest file. Does the extension have permission to access that url?
If it helps to your second problem (or anyone else): You can send a request to your background page like:
chrome.extension.sendRequest({var1: "var1value", var2: "value", etc},
function(response) {
//Do something once the request is done.
});
The Variable response
can be anything you want it to be. It can simply be a success or deny string. Up to you.
On your background page you can add a listener:
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
// Do something here
// Once done you can send back all the info via:
sendResponse( anything you want here );
// and it'll be passed back to your content script.
});
With this you can pass the response from your AJAX request back to your content script and do whatever you wanted to do with it there.