Hi all, I am trying to get the JSON output of directions between two points using the Directions API Web services. I am using an XmlHttpRequest (GET Method) in Javascript to get the results but gives me an error
"XMLHttpRequest cannot load http://maps.googleapis.com/maps/api/directions/json?origin=43.0480556,-76.1477778&destination=41.882853,-87.642059&avoid=tolls&sensor=false. Origin http://localhost:51724 is not allowed by Access-Control-Allow- Origin." If I paste the URL in browser and access it, it gives me the result properly. I am using IIS 7 as the server and I included the custom header "Access-Control-Allow-Origin" as ' * ' to allow CORS (Cross Origin Request Security), but still could not access the result. I donot have a working link of my code sample, so I am pasting the source below var url = "http://maps.googleapis.com/maps/api/directions/json? origin=43.0480556,-76.1477778&destination=41.882853,-87.642059&avoid=tolls&sensor=false.json"; var request = new XMLHttpRequest(); request.open("GET", url, true); request.setRequestHeader("Access-Control-Allow-Origin", "*"); request.onreadystatechange = function () { if (request.readyState == 4) { // === Parse the JSON document === var json = request.responseText; alert(json); } }; request.send(null); Please help me to sort out this. Thanks & Regards, SDee. -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
