javascript - Cannot get JSON data from URL -
apologies asking looks asked question cannot seem able data following url: http://www.strava.com/stream/segments/860503
i have tried following:
$(document).ready(function() { $.ajax({ url: "http://www.strava.com/stream/segments/860503&callback=?", datatype: "json", success: function(data) { $(document.body).append(data.latlng); } }); });
and:
$(document).ready(function() { $.getjson("http://www.strava.com/stream/segments/860503&callback=?", function(data) { $(document.body).append(data.latlng); }); )};
but not having luck. have fiddled around 'json' , 'jsonp', adding '&callback=?' url other things suggested on so, no avail.
any appreciated.
that particular url not support jsonp. neither provide support cross origin resource sharing (cors) via access-control-allow-origin
response header, therefore impossible directly call via ajax.
the requirement jsonp support server must output callback name function, passing json javascript object or array in argument function. example:
mycallback({ ...... });
a possible solution proxy ajax request through server side script on same domain, cross origin not problem server server requests.
Comments
Post a Comment