Multiple times i want to send messages from my tabs.sendMessage code but i am not getting response from the listner if i am using it multiple times....

7 views
Skip to first unread message

Manish Baldota

unread,
Sep 21, 2016, 3:18:08 AM9/21/16
to Chromium-Extensions-Announce
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse)
{
var sendResponse = sendResponse;
var client = new forcetk.Client();
client.setSessionToken(getValueFromCookie("sid"));
if (request.name == "forcequery")
{
var client = new forcetk.Client();
client.setSessionToken(getValueFromCookie("sid"));
client.describeGlobal(function(response)
{
console.log('results: ', response);
sendResponse({Results: response});
}, function(response)
    {
      console.log('error: ', response);
      sendResponse({Results: {}, error: true, response: response});
    });
    return true;
}
else if(request.name == "createJob")
{
client.createJob({
operation : 'insert',
object : 'Contact',
contentType : 'CSV'
}, function(response){
console.log('results1: ', response);
sendResponse({Results1: response});
});
}
});


how can i work with it for getting response from both....!!
Reply all
Reply to author
Forward
0 new messages