You did not indicate that this code is in the content of the script or background page. From looking at it, I assume this is part of the contents of the script.
, "[Object Object]", , , . "response.responseData", , "responseData" .
, , script, , .
.
script:
window.onload = function() {
alert('Ready');
sendMessage();
}
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
alert("The message from the background page: " + request.greeting);
sendResponse({
response: "Message received"
});
});
function sendMessage() {
chrome.runtime.sendMessage({
method: "postList",
post_list: "ThePostList"
}, function(response) {
alert("The response from the background page: " + response.response);
});
}
script:
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
alert('The message from the content script: ' + request.method);
sendResponse({
response: "Message received"
});
}
);
function sendDetails(sendData) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {
greeting: sendData
}, function(response) {
alert("The response from the content script: " + response.response);
});
});
}
, script , sendResponse .
, .