I am trying to call a ContentScript.js file function on click of a button in popu.html as below
In popup.html
$('#properties').live('click',function()
{
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(tab.id, {greeting: "hello"}, function(response) {
alert(response.farewell);
});
});
});
In my contentScript.js
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
if (request.greeting == "hello")
var pid = $('#ctlform').attr('action').split(".")[0].split("/")[2];
var qids = [];
$('fieldset').each(function()
{
var qid = $(this).prop('id').split('_')[1];
qids.push(qid);
});
var ReqDat = pid+"p_p"+qids.join('SCIA');
sendResponse({farewell: ReqDat});
else
sendResponse({}); // snub them.
});
But this does not work for me.. Please help me...
I have found the problem. The problem was { and } braces are missing in IF condition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With