0

I have written a jquery addon, with a little help from the internet, which retrieves data from Facebook and does as intended on all browsers tested so far apart from IE9.

I work for local government and unfortunately we still use IE9 in our builds (It was still IE8 a few weeks back!! So could have been a lot worse I expect :).

Anyways, I digress, I have added the section of code below which never completes in IE9, but does in IE10, and other browsers...

Can anyone explain/help me adapt or fix this snippet so that I can get it working in IE9?? And not break it in any other browsers in the process :)??

$.when($.getJSON(ogUSER), $.getJSON(ogPOSTS)).done(function (user, posts) {

        // user[0] contains information about the user (name and picture);
        // posts[0].data is an array with wall posts;

        var fb = {
            user: user[0],
            posts: []
        };

        var idxLimit = 0;
        $.each(posts[0].data, function () {

            // We only show links and statuses from the posts feed:
            if (this.type != 'link' && this.type != 'status') {
                return true;
            }

            // Copying the user avatar to each post, so it is
            // easier to generate the templates:
            this.from.picture = fb.user.picture.data.url;

            // Converting the created_time (a UNIX timestamp) to
            // a relative time offset (e.g. 5 minutes ago):
            this.created_time = relativeTime(this.created_time * 1000);

            // Converting URL strings to actual hyperlinks:
            this.message = urlHyperlinks(this.message);

            //remove all anchors
            //var content = $('<div>' + this.message + '</div>');
            //content.find('a').remove();
            //this.message = content.html();

            fb.posts.push(this);
            idxLimit++;
            if (idxLimit === 2) {
                return false;
            }
        });

In all browsers, not including IE9, if I insert a breakpoints anywhere within the .done() callback it stops execution and I can debug. With IE9 the breakpoint is not reached leading me to believe there is an issue with IE9 script engine and jQuery.when() API call, or the .done() callback method...

But, I'm just guessing at the mo... I've been searching the web for the last few hours to see if anyone else has happened upon a similar issue but to no avail. I hope some of the more experienced coders here can help... would be very much appreciated. Until then the search goes on :)

Thanks for your time folks ;)

PS. I don't receive any console errors what so ever in IE9 running the script...

TartanBono

Dennis Kriechel
  • 3,719
  • 14
  • 40
  • 62
  • 2
    add a `fail` handler and see if it is triggered. – epascarello Feb 03 '15 at 15:52
  • Just wondering, why using IE9 and not IE10/11? – A. Wolff Feb 03 '15 at 15:59
  • 2
    @A.Wolff Do you not know how Government agencies work? lol ;) – epascarello Feb 03 '15 at 16:00
  • @epascarello yes but from IE9 to IE10, oh wait, i see it now... :) – A. Wolff Feb 03 '15 at 16:02
  • @epascarello do you mean to the `when()` or each of the `getJSON()` calls? I tried but got 'Uncaught TypeError' for attempting to add to the `when()`. Looking at the jquery api and cannot see `fail` handler? but I do for the `getJSON()` methods... – TartanBono Feb 03 '15 at 16:18
  • http://api.jquery.com/ajaxError/ – epascarello Feb 03 '15 at 16:39
  • @epascarello Thanks for the link, I managed to add the handlers to the `getJSON()` methods before I just read your reply and in IE9 I get an error returned to the console... **No Transport** for each of the calls? Will this be same error returned following the`ajaxError` handler method? or should I register the handler as described in the link? – TartanBono Feb 03 '15 at 16:47
  • Are you making a cross domain call? or http to https? – epascarello Feb 03 '15 at 17:28
  • @epascarello yes, its a call to facebook open graph. I found [link](http://stackoverflow.com/questions/10315211/getjson-not-workin-in-ie) while looking around for a possible solution but it doesnt seem to have made any difference to my results :( The `ogPOSTS` variable is `https://graph.facebook.com/Facebook.ID/posts/?access_token=123456789101112|aAbB0OLslQ0X52k08my7JwqEzazZ&date_format=U&limit=5&callback=` (with proper FacebookID & access_token used), trying the correct URL in the IE9 browser returns the data expected... – TartanBono Feb 03 '15 at 17:37
  • http://stackoverflow.com/questions/10232017/ie9-jquery-ajax-with-cors-returns-access-is-denied – epascarello Feb 03 '15 at 17:44
  • @epascarello, thanks for that, been to use some of the techniques described in post but no joy so far... I think my situation seems to be calling https protocol from a page on http. I tried another endpoint on http and it returns ok... Thanks for your help so far... cheers – TartanBono Feb 04 '15 at 14:49

0 Answers0