
426 Capítulo 11
aponte seu lapís solução
Depois de completar o código, os itens da sua lista serão
clicáveis, o que carregará então os dados sobre o criptídeo
clicado e os colocará no mapa.
function getAllSightings(){
$.getJSON(“service.php?action=getAllSightings”, function(json) {
if (json.sightings.length > 0) {
$(“#sight_list”).empty();
$.each(json.sightings,function() {
var info = ‘Date: ‘ + this[‘date’] + ‘, Type: ‘ + this[‘type’];
var $li = $(“<li />”);
$li.html(info);
$li.addClass(“sightings”);
$li.attr(‘id’, this[‘id’]) ;
$li.click(function(){
getSingleSighting(this[‘id’] );
});
$li.appendTo(“#sight_list”);
});
}
});
}
function getSingleSighting( ...