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() + " " + $
if (street_address != "") {
} else {
$('#street_address').text("ADDRESS NOT FOUND");
error: function (xhr, status, 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
the url parameter, we substitute in the extendedFindNearby URL, which is http://ws . For our success function, we get the values for the
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
Try loading the story in your own browser , and see what the text looks like. You can
also download the full code from GitHub .
Search WWH ::

Custom Search