Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling Content script function from popup html is not working

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...

like image 397
Exception Avatar asked Apr 13 '26 10:04

Exception


1 Answers

I have found the problem. The problem was { and } braces are missing in IF condition.

like image 129
Exception Avatar answered Apr 15 '26 00:04

Exception