You cannot perform AJAX calls outside of your own domain. This is a
security feature to help prevent Cross Site Scripting (XSS) attacks.

There is a caveat, however. You can use $.getJSON() to fetch JSON
objects from remote sites. The docs use a flickr photo stream as a
good example of this. It allows you to include Javascript (and only
javascript) from a remote domain.

On Feb 4, 11:55 am, "mcandrew....@gmail.com" <mcandrew....@gmail.com>
wrote:
> If I try to call $.ajax with a fully qualified url, nothing happens at
> all:
>
>                 $.ajax(
>                 {
>                         type: "GET",
>                         url: "http://www.google.com/";,
>                         dataType: "html",
>                         success: function(data)
>                         {
>                                 alert(data);
>                         },
>                         error: function(XMLHttpRequest, textStatus, 
> errorThrown)
>                         {
>                                 alert(textStatus + errorThrown);
>                         }
>                 });
>
> If I call it without the "http://"; the alert in the error function
> shows "errorundefined":
>
>                 $.ajax(
>                 {
>                         type: "GET",
>                         url: "www.google.com",
>                         dataType: "html",
>                         success: function(data)
>                         {
>                                 alert(data);
>                         },
>                         error: function(XMLHttpRequest, textStatus, 
> errorThrown)
>                         {
>                                 alert(textStatus + errorThrown);
>                         }
>                 });
>
> If I call it with the url encoded, I also get "errorundefined" from
> the alert in the error function:
>
>                 $.ajax(
>                 {
>                         type: "GET",
>                         url: "http%3A%2F%2Fwww%2Egoogle%2Ecom%2F",
>                         dataType: "html",
>                         success: function(data)
>                         {
>                                 alert(data);
>                         },
>                         error: function(XMLHttpRequest, textStatus, 
> errorThrown)
>                         {
>                                 alert(textStatus + errorThrown);
>                         }
>                 });
>
> All of the examples I see show calling this function with a relative
> URL, was it not intended to go used to download content from other
> domains?

Reply via email to