So I've got my content script set up to send a request to my background page. Response is returned and is the value from local storage that I'd expect, but I cannot seem to work with the returned value. If I try and assign the response to a variable, and then alert that variable to check its value it ends up being a blank alert box. If I write the response to the console log it is the value I'm expecting.

This works:
Code:
function getStoredPrefs()
{
	chrome.extension.sendRequest({name: "getPreferences"}, function(response) { console.log(response.prefEnableKey) ;} );
}
This fails:
Code:
function getStoredPrefs()
{
	var responseVal = "";
	chrome.extension.sendRequest({name: "getPreferences"}, function(response) { responseVal = response.prefEnableKey ;} );
	alert(responseVal);
}
Side note: I seem to be getting two alerts even though I'm only calling this function once in the content script. Any ideas why?