In JS is it possible to fetch the content of a web page assigning it to a variable? For example, why the following toy code does not work?
var req = new XMLHttpRequest();
req.open('GET', 'http://www.google.com', false);
req.send(null);
if(req.status == 200)
alert(req.responseText);
Is there a better method/code?