views:

75

answers:

1

Hi Guys , why I have this kind of error in my code :

"Error: jsonFlickrApi is not defined"

    $.getJSON('http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=669158895706254986e97354a3c7e9a9&photoset_id=72157623477817483&extras=original_format&format=json&jsoncallback;=?',
    function(data){
        var classShown = 'class="lightbox"';
        var classHidden = 'class="lightbox hidden"';


        $.each(data.photoset.photo, function(i, rPhoto){
            var basePhotoURL = 'http://farm' + rPhoto.farm + '.static.flickr.com/'
                + rPhoto.server + '/' + rPhoto.id + '_' + rPhoto.secret;
......

there are syme issues in JSON datatype or something else, suggest me how to fix it , pls

Thanks

+1  A: 

The end of your URL is a bit off, this:

....&jsoncallback;=?

Should be:

....&jsoncallback=?

jQuery fills in this method on it's own with a dynamically named function (your function(data) is converted to this named function or JSONP to work). Since the format's off it's not replacing this correctly and the default method is jsonFlickrApi.

If you visit the url directly (this is without the callback) you'll see it looks like this:

jsonFlickrApi({ ... })

If you do provide a callback (like this url), it looks like this:

myFunction({ ... })

This is what jQuery should do, but due to the malformed URL it isn't replacing the ?, fix it and it'll do that, and it'll call the proper method, instead of the default one.

Nick Craver
Damn, I am so stupid, sorry man, an thanks !!
Alexander Corotchi