views:

109

answers:

3

Hello,

I have a blog on google (blogger) and i want to get json data from external website in order to integrate into my posts. I used jquery library and getJson function in order to retrieve the json data but nothing is returned.

Blogger restrict any jquery external calls ? Have any idea? Thank you

+1  A: 

you can't make cross domain ajax calls

ErsatzRyan
A: 

I know this is an old post, but I was trying to figure this out and this post is still ranking highly in Google, so...

You can, check out http://code.google.com/apis/gdata/docs/json.html for information. But, look at the JSONP mode used by jquery and you'll see how to do it. For example, the following code shows how to get a comment feed from the Blogger API:

    var BloggerImporter = {

    getComments : function(username){

        var feedURL = "http://"+username+".blogspot.com/feeds/comments/default";

        var paras = {
            alt : 'json-in-script'
        };

        $.ajax({
            url: feedURL,
            type: 'get',
            dataType: "jsonp",
            success: BloggerImporter.onGotCommentData,
            data: paras
        });


    },

    /**
     * Parse the JSON comment data returned by the Google Blogger API
     */
    onGotCommentData : function(data){

        var feed = data.feed;
        var entries = feed.entry || [];
        var txt = "";

        for (var i = 0; i < entries.length; ++i) {
            var entry = entries[i];
            var title = entry.title.$t;
            txt += title;
        }

        alert(txt);
    }
}
Mike P