This is my AJAX code that I want to use to get data from an API to show in a div
. When I query the data I get value.application_icon
is null
so this file is blank
I want to use value.application_image
when value.application_icon
is null
. I don’t know how to config this.
$.ajax({
type: "GET",
contentType: "application/json",
url: endpoint + apiKey,
success: function(response) {
$.each(response, function(key, value) {
$('.first-set').append(
'<li><a href="' + value.application_base_url + '' + value.application_url + '"> n ' +
'<div> n ' +
'<i class="' + value.application_icon + '"></i> n ' +
'</div>' +
'<span>' + "Search" + '</span>' +
'</a></li>'
);
})
},
2
Answers
Try this code snippet.
Or else use like this with for loop
hope it will help you.