php - NOOB: Parse API data and output one item -


apologies how simple question is.

i have link citymapper api:

https://developer.citymapper.com/api/1/traveltime/?startcoord=51.513895%2c+0.021222&endcoord=51.524006%2c+-0.115490&key=8b3e89fd32441463296274661805caba 

when point browser there gives me:

{"travel_time_minutes": 51, "diagnostic": {"milliseconds": 3036}}

i trying pull out 1 item it; "51".

i want display on html webpage say: "51 minutes work"

i know simple, can't work out of documentation on how deal this.

you can use jquery $.ajax function this.

var url = 'https://developer.citymapper.com/api/1/traveltime/?startcoord=51.513895%2c+0.021222&endcoord=51.524006%2c+-0.115490&key=8b3e89fd32441463296274661805caba';      $.ajax({    method: 'get',    url: url,    datatype: 'jsonp',        crossdomain: true,    success: function(data){      $('.data').html(data.travel_time_minutes + ' minutes work');    }          });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>    <div class="data"></div>


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -