Not very familiar with XMLHttpRequest
s, but am using the cross-origin function in Google Chrome extensions. This works great (I can confirm I get the appropriate data that I need), but I can't seem to store it within the 'response' variable.
I'd appreciate any help.
function getSource() {
var response;
var xmlhttp;
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
response = xmlhttp.responseText;
//IM CORRECTLY SET HERE
}
//I'M ALSO STILL WELL SET HERE
}
//ALL OF A SUDDEN I'M UNDEFINED.
xmlhttp.open("GET","http://www.google.com",true);
xmlhttp.send();
return response;
}