I am trying to send a url from content.js to background.js to make an ajax request there.
In content.js I have the following code. By the way, this message sending from content.js to background.js works and I have tested it. But the problem is that I am getting no response from background.js back. I have also tested that ajax request was made successfully.
$(document).on('click', '.readmore a', function(event) {
    event.preventDefault();
    var link = $(this).attr('href');
    chrome.runtime.sendMessage(extractFacebookUrl(link), function(response){
        console.log(response); //nothing get consoled out here.
    });
});
In background.js, I have the following code.
chrome.runtime.onMessage.addListener(function(url, sender, response){
    $.get(url, function(data){
        obj = {'data' : data, 'link' : url}
        //alert(data); //This alert shows that ajax request was successful.
        response(obj); //But this returns nothing to content.js. Why?
    });
});
 
    