Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7638239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:07:36+00:00 2026-05-31T08:07:36+00:00

I have a JavaScript function that I use to call the Facebook API and

  • 0

I have a JavaScript function that I use to call the Facebook API and get a list of posts from a wall. In Firefox, Chrome and Safari this works with no issue, but in Internet Explorer 9 (I haven’t tested below yet), it just doesn’t do anything, the UI stays blocked, but I do not seem to get any messages that point to an error. I have a feeling it may have something to do with the JSON being returned and the Internet Explorer parser, but I can’t be sure at this point.

After being pointed back to the Facebook SDK, I re-implemented using that (I am not sure why I left it before now), and it all seems to play nicely with Internet Explorer now.

Old Code

var getFeed = function (name, type, limit, accessToken, apiKey, containerId) {
    var list_url = "https://graph.facebook.com/" + name + "/" + type + "?limit=" + limit + "&access_token=" + accessToken + "&api_key=" + apiKey;
    var html = "";

    displayHelper.blockUI(containerId, "Loading Feed");
    $.getJSON(list_url, function (json) {
        //Loop through and within the data array to retrieve the variables.
        $.each(json.data, function (i, fb) {
            var msg = (typeof (fb.message) != "undefined") ? fb.message : "";
            var link = (typeof (fb.link) != "undefined") ? fb.link : "";
            var pic = "";
            // msg = (typeof(fb.story) != "undefined") ? fb.story : msg;
            var type = (typeof (fb.type) != "undefined") ? fb.type : "";
            var includeInOutput = true;

            pic = getPicture(fb.from.id);

            switch (type) {
                case "story":
                    msg = fb.story;
                    break;
                case "link":
                    if (typeof (fb.message) != "undefined")
                        msg = fb.message;
                    else if (typeof (fb.caption) != "undefined")
                        msg = fb.caption;
                    else if (typeof (fb.story) != "undefined")
                        msg = fb.story;
                    else if (typeof (fb.name) != "undefined")
                        msg = fb.name;
                    break;
                case "video":
                case "photo":
                    if (typeof (fb.message) != "undefined")
                        msg = fb.message;
                    else if (typeof (fb.story) != "undefined")
                        msg = fb.story;
                    break;
                case "status":
                    if (typeof (fb.message) != "undefined")
                        msg = fb.message;
                    else if (typeof (fb.story) != "undefined")
                        msg = fb.story;
                    break;
                default:
                    includeInOutput = false;
                    break;
            }

            if (includeInOutput) {
                //build html for this list item
                html += '<dl class="fb-item">';
                html += "<dt>" + fb.from.name + "</dt>";
                html += (pic != '') ? '<dd class="img"><img src="' + pic + '" />' : '';
                html += '<dd class="msg">' + msg + '</dd>';

                /*html += '<a href="' + link + '" class="fb_link" target="_blank">'
                + msg  + "(" + type + ")"
                + "</a>";*/

                html += '<dd class="links">';
                html += '<span>' + fuzzyTime(fb.created_time.replace(/-/g, '/')) + '</span>';

                if (typeof (fb.actions) != "undefined") {
                    if (fb.actions[1].name == "Like")
                        html += "<a href='" + fb.actions[1].link + "' class='fb_link' target='_blank'>Like</a> - ";

                    if (fb.actions[0].name == "Comment")
                        html += "<a href='" + fb.actions[0].link + "' class='fb_link' target='_blank'>Comment</a>";
                }
                html += '</dd>';
                html += "</dl>";
            }

        }); /* end .each */

        //html += "</ul>";
        $(containerId).html(html);
        $(containerId).unblock();

    }); /* end getJSON */

} /* end hetFeed

New Code – UPDATED again. The picture was not returning so I extracted the message and build parts into its own method and built the message on the call back of the get picture. Before I was doing it in a blocking way, just wrong! Hopefully this will help someone one day.

var postMessage = function (fb, containerId) {
    FB.api("/" + fb.from.id + "/?fields=picture", {}, function (p) {
        var pic = p.picture;
        var msg = (typeof (fb.message) != "undefined") ? fb.message : "";
        var link = (typeof (fb.link) != "undefined") ? fb.link : "";
        var type = (typeof (fb.type) != "undefined") ? fb.type : "";
        var includeInOutput = true;
        var html = "";

        switch (type) {
            case "story":
                msg = fb.story;
                break;
            case "link":
                if (typeof (fb.message) != "undefined")
                    msg = fb.message;
                else if (typeof (fb.caption) != "undefined")
                    msg = fb.caption;
                else if (typeof (fb.story) != "undefined")
                    msg = fb.story;
                else if (typeof (fb.name) != "undefined")
                    msg = fb.name;
                break;
            case "video":
            case "photo":
                if (typeof (fb.message) != "undefined")
                    msg = fb.message;
                else if (typeof (fb.story) != "undefined")
                    msg = fb.story;
                break;
            case "status":
                if (typeof (fb.message) != "undefined")
                    msg = fb.message;
                else if (typeof (fb.story) != "undefined")
                    msg = fb.story;
                break;
            default:
                includeInOutput = false;
                break;
        }

        if (includeInOutput) {
            //build html for this list item
            html += '<dl class="fb-item">';
            html += "<dt>" + fb.from.name + "</dt>";
            html += (pic != '') ? '<dd class="img"><img src="' + pic + '" />' : '';
            html += '<dd class="msg">' + msg + '</dd>';

            /*html += '<a href="' + link + '" class="fb_link" target="_blank">'
            + msg  + "(" + type + ")"
            + "</a>";*/

            html += '<dd class="links">';
            html += '<span>' + fuzzyTime(fb.created_time.replace(/-/g, '/')) + '</span>';

            if (typeof (fb.actions) != "undefined") {
                if (fb.actions[1].name == "Like")
                    html += "<a href='" + fb.actions[1].link + "' class='fb_link' target='_blank'>Like</a> - ";

                if (fb.actions[0].name == "Comment")
                    html += "<a href='" + fb.actions[0].link + "' class='fb_link' target='_blank'>Comment</a>";
            }
            html += '</dd>';
            html += "</dl>";
        }

        $(containerId).append(html);
    });
}

var getFeed = function (name, type, limit, accessToken, apiKey, containerId) {

    var list_url = "https://graph.facebook.com/" + name + "/" + type + "?limit=" + limit + "&access_token=" + accessToken + "&api_key=" + apiKey;
    var fullHtml = "";

    helper.blockUI(containerId, "Loading Feed");
    var path = "/" + name + "/" + type;

    FB.api(path, { access_token: accessToken, api_key: apiKey, limit: limit }, function (json) {
        console.log(json);
        var data = json.data;
        for (var i = 0, l = data.length; i < l; i++) {
            var fb = data[i];

            postMessage(fb, containerId);

        } //End For

        $(containerId).unblock();
    });

} /* End getFeed */
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:07:37+00:00Added an answer on May 31, 2026 at 8:07 am

    You might want to try to use the sdk anyway, that way you can know better where exactly is the problem with your code in IE.

    If you do this:

    var path = name + "/" + type;
    var params = limit == null ? {} : { limit: limit };
    
    FB.api(path, "post", params, function(json) {
        ......
    });
    

    It should pretty much do the same as the code you posted (minus the actual handling of the results). If you try it and this works in IE then the problem was with how you communicated with facebook, otherwise it’s in the part that handles the results from facebook.

    One thing for sure, this approach (of using the sdk) is simpler and more elegant, not to mention that in this way, changes facebook are making on their on end won’t affect you (in most cases).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Javascript function that is called from the onchange method in a
I have a Javascript function that accepts a list of HTML nodes, but it
I have a javascript function that posts data to a validation script and grabs
I have a javascript function that calls a generic function to make an ajax
I have a javascript function that accepts a number and performs a mathematical operation
I have a javascript function that checks for a date range. Is there any
I have a javascript function that is being built to animate the collapse of
I have a javascript function that toggles the display for rows in a table.
I have a javascript function that changes the innerHtml of a <div> tag to
I have one javascript function that used to display the menu and content in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.