HTML and CSS Reference
In-Depth Information
Figure 2-2. A Geolocated tale
$('#city').text("CITY NOT FOUND");
}
var street_address = $(loc_resp).find("streetNumber").text() + " " + $
(loc_resp).find("street").text();
if (street_address != "") {
$('#street_address').text(street_address);
} else {
$('#street_address').text("ADDRESS NOT FOUND");
}
},
error: function (xhr, status, error) {
alert(error);
$('#city').text("CITY NOT FOUND");
$('#street_address').text("ADDRESS NOT FOUND");
}
})
Most of the
$.ajax()
parameters are identical to those for the temperature query. For
placename
(typically corresponds to city),
streetNumber
, and
street
elements in the
XML from GeoNames, and update the corresponding
<span>
s in the HTML. For our
error
function, we update the
<span>
s with boilerplate “NOT FOUND” text.
Figure 2-2
shows what the final story looks like, post-geolocation, if you happen to be
visiting O'Reilly Media's Cambridge, Massachusetts, office on a warm, late-summer
day.
Try
loading the story in your own browser
,
and see what the text looks like. You can