O'Reilly logo

HTML5 Web Application Development By Example Beginner's guide by J.M. Gustafson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – getting JSON data

Now let's do the same thing as we did in the previous section, except that we will get the data from a file containing JSON formatted data rather than XML. The concept is the same, except that what we get back from the Ajax call is a JavaScript object rather than an XML document. You can find the code for this example in Chapter 8/example8.2.

First let's define our JSON file, which we will name weather.json, and put it in the data folder:

{ "location": { "city":"Your City" } ,"current_observation": { "weather":"Clear", "temperature_string":"38.3 F (3.5 C)", "wind_string":"From the WSW at 1.0 MPH Gusting to 5.0 MPH", "feelslike_string":"38 F (3 C)", "relative_humidity":"71%", "icon_url":"images/nt_clear.gif" } ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required