I want to know how my content script can communicate with the backend script. I mean sending request from content script and get responce from backend script based on request.
Asked
Active
Viewed 50 times
-2
-
1https://developer.chrome.com/extensions/messaging – Haibara Ai Jun 23 '16 at 07:59
-
@HaibaraAi Simple as that. I really wonder if people use search engines these days. – Transcendental Jun 23 '16 at 12:27
1 Answers
0
You should refer to message passing: https://developer.chrome.com/extensions/messaging
When sending a message from content script to background script you'll simply use:
chrome.runtime.sendMessage({greeting: "hello"}, function(response) {
console.log(response.farewell);
});
When it's the other way around you'll need to specify the tab as well (please refer to the link above).

Eran
- 133
- 7