In the process of learning Ajax requests using jQuery, I tried to load google home page on the click of a link. So I wrote something like:
$("#ajax").click (function (event) {
$("#g").html("Loading...");
$("#g").load("http://www.google.com");
event.preventDefault ();
});
And somewhere in body:
<a id="ajax" href="http://www.google.com">Load file ajax way</a>
<div id="g">Click the above link to load the page...</div>
Which didn't work and initially I thought there is some syntax error or something. But later when I replaced the google url with a static html file on server, it worked correctly.
$("#g").load("Temp.htm");
Is it designed to work like this (if yes, why?) or am I doing something wrong?
EDIT: Please can anyone explain (or refer) the security problem introduced by cross domain ajax calls? In other words, why it is safe to open another browser tab and open google but NOT from within the page? Is it to protect caller or callee?