jQuery getJSON - warunek
Mam kod, który pobiera i wyświetla dane (getJSON). Co zrobić, aby w przypadku, gdy plik z danymi w JSON będzie pusty wyświetlić odpowiedni komunikat?
$(document).ready(function() {
$('#message').html('<p>Checking...</p>');
$.getJSON('file.json', function(data) {
$('#message').empty();
data = data[ 0 ];
var html = '<p>';
html += 'See ' + data['name'] + '</p>';
$('#message').append(html);
});
return false;
});