I am trying to load the content of google.com in a div. I am using
$('#loadGoogleBtn').click(
function(){ alert ( 'loading' );
$('.container').load('http://google.com');
alert ( 'done' );
});
But it is not working, instead it is giving me 301 HTTP status. [ Thanks to firebug :) ]. Why it is happening.
Note i am able to access google.com
You can't make an XmlHttpRequest to a remote domain like this, it's blocked by the same-origin policy. Firefox chooses to present this as a 301, how the browser blocks it (read: chooses to enforce the policy) varies, but you'll always get an empty response.
This prevents you from doing something like:
$('.container').load('http://myBank.com');
and using my stored cookies, etc to login (also protected by the same cross-domain policy rules).