json - Google Maps Directions API, No 'Access-Control-Allow-Origin' header is present -


if send ajax , set type json.

$.ajax({         url: $url,          type: "get",            datatype: 'json',         cache: false,         success: function(response){                                       alert(response);                            }                }); 

will have

no 'access-control-allow-origin' header present on requested resource. origin 'http://127.0.0.1' therefore not allowed access."


i have used type jsonp

$.ajax({         url: $url,          type: "get",            datatype: 'jsonp',         cache: false,         success: function(response){                                       alert(response);                            }                }); 

will have error

uncaught syntaxerror: unexpected token :

line 2

{    "destination_addresses" : [ "3 king ling rd, tseung kwan o, hong kong" ],    "origin_addresses" : [ "hong kong, kwun tong, 鴻懋工業大廈" ],    "rows" : [       {          "elements" : [             {                "distance" : {                   "text" : "6.9 km",                   "value" : 6936                },                "duration" : {                   "text" : "11 mins",                   "value" : 656                },                "status" : "ok"             }          ]       }    ],    "status" : "ok" } 

but there no wrong

please me!!!


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -