HTML5 APPLICATIONS DEVELOPMENT MANUAL

(lu) #1

Let’s make now the call to the weather api using a$.getJSON().Inside of


the parenthesis we will put the url till before our unique key, where will need


to change the values for lat, lon and appid.


As the location returns from the ipinfo.io as a string with to values,


let’s split the string at the comma (,), that will make it an array with the exact


values that we need.


Now we can modify in the url, the values for lat with loc[0] (the first


element of the array we just created by splitting the location string ), for


lonwith loc[1] (the second element of the array) and for the appid our


API_KEY variable.

Free download pdf