Fetching image url from jquery ajax call -


trying give src attribute created element. src should url retrieved giphy api. can console.log response data , fine, cannot seem jquery creating element house gif correct.

$('.spawn-button').on("click", function(event) {   event.preventdefault();    $.ajax({     url: query + $(this).html() + apikey + limit,     method: 'get'   }).done(function(response) {      for(var = 0; < response.data.length; i++){       // console.log(response.data[i]);       // console.log(response.data[i].images.original);       $('.gif-container').append("<img src=" + response.data[i].images.fixed_height + ">");     }   }); }); 

can try below code . per documentation @ https://developers.giphy.com/docs/ fixed_height object has url property gif image

$('.spawn-button').on("click", function(event) {    event.preventdefault();      $.ajax({      url: query + $(this).html() + apikey + limit,      method: 'get',      success: function(response) {       for(var = 0; < response.data.length; i++){        // console.log(response.data[i]);        // console.log(response.data[i].images.original);        $('.gif-container').append("<img src=" + response.data[i].images.fixed_height.url + ">");      }    });  });


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -