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
Post a Comment