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 :
{ "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
Post a Comment