I'm trying to reference information from my background.html page (that is accessing localStorage) by sending a request from my content script using the messaging API. I am able to successfully send and receive a response, but what I am able to do with the response is throwing me for a loop.
This works:
This doesn't work:Code:function getStoredPrefs() { chrome.extension.sendRequest({name: "getPreferences"}, function(response) { console.log(response.prefEnableKey) ;} ); }
Code:function getStoredPrefs() { var responseVal = ""; chrome.extension.sendRequest({name: "getPreferences"}, function(response) { responseVal = response.prefEnableKey ;} ); alert(responseVal); }
Side note: When I call the alert in the portion that is not working, it seems to fire twice (two separate alert boxes received) even though I am only calling it once. Any ideas?
Thanks in advance for any assistance.


LinkBack URL
About LinkBacks



Reply With Quote
