开发者

Flickr API Error, Json callback

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 开发者_StackOverflow社区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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜