0

The following works perfectly for FF, Chrome and Safari but IE rejects it.

$(function() {

  var access_token = location.hash.split('=')[1];
  $.ajax({
    type: "GET",
    dataType: "jsonp",
    cache: false,
    url: "https://api.instagram.com/v1/users/1055710/media/recent
           /?access_token=1055710.c0af960.953163eb1bf44607a94ad482e33b5b68",
    success: function(data) {        
      for (var i = 0; i < 6; i++) {
        $(".instagram").append($("<div class='instagram-placeholder'>")
                       .append($("<a target='_blank'>")
                         .attr("href", data.data[i].link)
                       .append($("<img class='instagram-image'>")
                         .attr("src", data.data[i].images.thumbnail.url))))   
      }     
    }
  });
});

How can I make it work in IE?

HaskellElephant
  • 9,819
  • 4
  • 38
  • 67
jhui
  • 77
  • 2
  • 12
  • What ie version are you using? It depends on the version how bad this programm is. – Chris Mar 04 '11 at 12:58
  • How does it reject it. Are you getting the response back? Is it failing authentication? – uncaught_exceptions Mar 04 '11 at 13:01
  • Have you set the propper header when sending your data ? – Tyde Mar 04 '11 at 13:17
  • Hi @Chris I'm using version 8... – jhui Mar 04 '11 at 13:17
  • Hi @doc_180 - I'm getting responses back in Chrome, FF and Safari, just not IE. – jhui Mar 04 '11 at 13:18
  • Hi @Tyde - What would the proper header be? – jhui Mar 04 '11 at 13:19
  • Have you tried alerting something in the success function that is before the loop to make sure it's returning anything at all? All it's a good practice to add an Error event as well with a simple alert to let you know it failed. `( typeof console !== 'undefined' ) ? console.log('I is broke') : alert('I is broke and alert');` – Seth Mar 04 '11 at 13:20
  • http://stackoverflow.com/questions/3350778/modify-http-headers-for-a-jsonp-request – Seth Mar 04 '11 at 13:21
  • @Seth - I'm getting I is broke. What does that mean? - Sorry to be a n00b! – jhui Mar 04 '11 at 13:34
  • If you placed it in the success method then it would mean your data is returning and that you're not parsing it correctly for IE. If it's coming from the error method it means IE isn't receiving the JSONP and it could be incorrectly formatted. If it's in the success try $.parseJSON( data ) before your loop and that will create a JSON object to work with. – Seth Mar 04 '11 at 13:42
  • I think you need a P3P privacy compact: See this: http://stackoverflow.com/questions/8364037/jsonp-java-servlets-and-internet-explorer/8365386#8365386 – Joe Mar 21 '12 at 19:35

1 Answers1

1
$(".instagram").append("<div class='instagram-placeholder'><a target='_blank' href='" + data.data[i].link +"'><img class='instagram-image' src='" + data.data[i].images.thumbnail.url +"' /></a></div>");

Use this inside your for loop and you will have the element list show in IE as well. Looks like IE don't like the long chaning or don't add the element propperly when chaning.

Tyde
  • 242
  • 1
  • 3
  • 11