Hi Eric,

As John pointed out, you can't use $.getJSON() across domains, because it
uses XMLHttpRequest which is subject to the same-domain policy.

I saw that you'd also tried to use my JSON plugin, which does handle
cross-domain requests because it uses a dynamic script tag instead of
XMLHttpRequest. You came pretty close to getting it working. I updated your
code, with a description of what I changed, and posted it in a reply to your
comment:

http://mg.to/2006/01/25/json-for-jquery#comment-5010

One big problem was that the Flickr feed API doesn't support a
user-definable callback function name as the plugin expects. You can still
use the plugin, but you have to provide a global callback function with a
specific name, instead of the anonymous callback that the JSON plugin and
$.getJSON normally use.

There's a full explanation at the link above, but here's the updated code
for the curious:

function log() {
    if( window.console )
        console.debug.apply( console, arguments );
    else
        alert( [].join.apply( arguments, [' '] ) );
}

$(document).ready(function(){
    log( 'Document Ready' );
    var url =
'http://api.flickr.com/services/feeds/[EMAIL PROTECTED]&for
mat=json';
    log( 'url:', url );
    $().json( url );
});

function jsonFlickrFeed( json ) {
    log( 'json feed received:', json );
}

-Mike

> From: neuromystical
> 
> Can anyone tell me what is wrong with the following. I am new 
> to JQuery and I do not know if I am doing anything wrong 
> here. I am not just looking for an answer, I am trying to 
> understand what is going on here and I do not understand by 
> looking at the existing jquery.js I have or searching the web 
> for jquery stuff. I realize their are Flickr scripts to addon 
> to JQuery, but I want to understand JQuery.
> 
> $(document).ready(function(){ //INIT Stuff
>    // Your code here
>       alert('Document Ready');
>       var url =
'http://api.flickr.com/services/feeds/[EMAIL PROTECTED]&api
_key=6470b0f7c050146a3dd9e861966092c5&format=json';
>       alert(url);
>       $.getJSON(url,function(json)
>         {
>             alert('test');
>             //alert('I received the json and put it in the json var : ' +
json.toString());
>         }
>       //alert('nothing after this');
>       );
>  });

Reply via email to