开发者

How to load JSONP data in IE?

开发者 https://www.devze.com 2023-02-14 16:01 出处:网络
The following works perfectly for FF, Chrome and Safari but IE rejects it. $(function() { var access_token = location.hash.split(\'=\')[1];

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)
       开发者_如何学C                .append($("<img class='instagram-image'>")
                         .attr("src", data.data[i].images.thumbnail.url))))   
      }     
    }
  });
});

How can I make it work in IE?


$(".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.

0

精彩评论

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