I use a AJAX-Jquery post to calculate the time to get from A to B using Google API.
But i get the error "XMLHttpRequest cannot load https://maps.googleapis.com/maps/api. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access."
I've read a lot of posts and tried several solutions. None of them worked.
with different variants of headers in my .php page
header("Access-Control-Allow-Origin", "*");
header('Access-Control-Allow-Credentials: true');
modifing my .htaccess file:
Header set Access-Control-Allow-Origin "*"
installing Chrome extension Allow-Control-Allow-Origin
The third choise allowed me to test my code but is not a real solution. Does anyone succeded to solve this?
What you're going to need is
JSONP or "JSON with padding" is a communication technique used in JavaScript programs running in web browsers to request data from a server in a different domain, something prohibited by typical web browsers because of the same-origin policy.
Somewhere inside your AJAX call, you're going to make sure that the dataSet
is jsonp
.