0
我想从sendResponse到chrome.runtime.sendMessage的反应,但它总是呈现不确定的,下面是我的代码:没有得到响应的Chrome extention
chrome.runtime.sendMessage(JSON.stringify(contact), function(response) {
console.log('Response: ', response); // This is showing undefined
});
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
contact.addContact(request, function() {
sendResponse({success: 'true'});
});
});
所以,当我通过sendResponse({成功:true})应该在chrome.runtime.sendMessage的回调函数中接收,但不是它显示为undefined。
是的工作,非常感谢... :) –