<button id='ajax'>Make AJAX Call</button>
<!-- Post Info -->
<div style='position:fixed;bottom:0;left:0;
background:lightgray;width:100%;'>
About this SO Question: <a href='http://stackoverflow.com/q/19793406/1366033'>Issue using jQuery to do a google maps api call</a><br/>
Google Maps API Documentation <a href='https://developers.google.com/maps/documentation/directions/'>Directions</a><br/>
jQuery Documentation: <a href='http://api.jquery.com/jQuery.getJSON/'>Get JSON</a><br/>
<div>
JavaScript
var mapsUrl = 'http://maps.googleapis.com/maps/api/directions/json'+
'?origin=Toronto&destination=Montreal&sensor=false';
$(function(){
$("#ajax").click( function() {
$.ajax({
url: "http://wsmio.siur.com.co:8083/apiMIO/jaxrs/pevrs",
dataType: 'jsonp',
cache: false,
success: function (data) {
alert(showTime(data));
}
});
});
});
function proxyUrlJsonp(url) {
var encodedUrl = encodeURIComponent(url);
var proxyUrl = 'http://jsonp.guffa.com/Proxy.ashx?url=' + encodedUrl;
return proxyUrl;
}
function showTime(data) {
var leg = data.routes[0].legs[0];
var msg = 'Time from ' +
leg.start_address + ' to ' +
leg.end_address + ' is ' +
leg.duration.text + '!';
return msg;
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.