[OSRM-talk] OSRM - cannot read JSON responce

sergi_jini s.jishkariani at gmail.com
Mon Dec 28 07:16:57 UTC 2015


Firstly, thanks to all contributors of OSM!

I have setup OSRM engine on CentOS VM (
https://github.com/Project-OSRM/osrm-backend/wiki) and if I query it via
browser directly it is working fine, returning route.json file.

My problem is that I can't get it working via Javascript. Getting below
error if i query it from my website:

var resultJSON = {};

    dataType: "json",
    async: false,
    cache: true,
    url: ',42.667269338144&loc=42.2695544,42.7017228
    success: function(data) {
    resultJSON = data;


*"Cross-Origin Request Blocked: The Same Origin Policy disallows reading
the remote resource at,42.667269338144&loc=42.2695544,42.7017228
(Reason: CORS header 'Access-Control-Allow-Origin' missing)."*
As stated in APi manual, jsonp={callback name} must be added to request
URL, which is not helping either. Tried different variations with jsonp,
cache (which is adding extra _ parameter to the URL), getJson method,
crossdomain : true ...Thinking to read the json on server side via PHP*
file_get_contents* and then send it to front end via json, but can't get it
working either. I believe there must be more smooth way as it is mentioned
in the API manuals.

I would really appreciate if anyone can help me with a working code.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/osrm-talk/attachments/20151228/3e9901d2/attachment.html>

More information about the OSRM-talk mailing list