I am working on a chrome extension. I am using chrome.runtime.sendMessage() API to send a URL to another js file. When I receive the URL in other file through chrome.runtime.onMessage.addlistener(function(sent,sender,sendResponse){...}). I call another method or function checkUrl(url){...} to which I pass the URL sent by the other file as a message. and this function returns the Ajax call to that URL. And then I use .then() promise in the scope where I have called the checkUrl(url){...} function. I get the response perfectly and after displaying the response in the console, I send that response back to the sender file where I got the message from. But I am not getting any response on the content script I don't know if I have mistaken something...
Content Script Code to send Message
chrome.runtime.sendMessage({type:"postUrl",mess:url},function(r){
   console.log(r.res);
});Script I am getting the message and then trying to send response back
chrome.runtime.onMessage.addListener(function(sent,sender,sendResponse){
 alert("message recieved");
 var str;
 switch(sent.type){
  case "postUrl":{
        checkUrl(sent.mess).then(function(r){
           console.log("Promise Test : " + r);
           sendResponse({res:r})
     });
     break;
  }
 }
});
function checkUrl(url){
    return $.ajax({
       method:"GET",
       url:"http://www.bitbaysolutions.com/connections.php?fbPostUrl=true",
       data:{
        url:url
       }
    })
}