I am passing the data from content script to background.html in the below code but it doesn’t works for me due to some reason..Here is the code..
Contentscript.js
var a1 ="Shan";
chrome.extension.sendRequest({method:"text",txt:a1}, function(response) {
d=response.data;
alert(d);
});
background.html
if(request.method == "text")
{
sendResponse({data:request.key});
}
else
{
sendResponse({data:request.key});
}
My question is why I am not able to pass the variable “a1” to background.html?? Whether it can’t be done?
Because the key is named
txt, notkey.Warning: I’ve experienced that you cannot recycle the
sendResponsemethod. After firingsendResponse, the extension will not responde to futuresendResponsecalls.So, only one
sendResponsefor eachchrome.extension.sendRequest.