jquery - Javascript HTML - how to consume web api -


i trying build chrome app (using html , javascript), in want to:

  1. call api, instance let's take google maps web api (below).

google maps json api: http://maps.googleapis.com/maps/api/geocode/json?address=vancouver

  1. fetch particular value: lets long_name" : "vancouver" (highlighted in below screenshot)

enter image description here

  1. store it's value "vancouver" in variable , use later.

in chrome apps, know can use html , javascript/jquery (correct me if wrong jquery). not sure how use javascript/jquery , call above api , consume particular value.

you can use jquery rest client, it's easy implement

edit

add libraries:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>  <script src="http://jpillora.com/jquery.rest/dist/1/jquery.rest.min.js"></script> 

to resolve "vancouver" , store in variable should be:

var longname = null;  var client = new $.restclient('http://maps.googleapis.com/maps/api/');  client.add('geocode', {striptrailingslash: true});  client.geocode.read('json', {address: 'vancouver'}).done(function (data){   longname = data.results[0].address_components[0].long_name; }); 

Comments

Popular posts from this blog

c# - Where does the .ToList() go in LINQ query result -

Listeners to visualise results of load test in JMeter -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -