I need to fetch source code from a given url. I've tried using :
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://google.com', false);
xhr.send(null);
var data=xhr.responseText;
But this does not work for me. So, I tried using ajax given in one of the SO link but it didn't work for me :
$.get( "http://google.com", function( data ) {
$( ".result" ).html( data );
alert( "Load was performed." );
});
Can someone please guide me what I am doing wrong here ? Thanks in advance.