I am developing a GIS Map Java web application using jsp , javascript / ajax / jQuery, which deploys on a tomcat server . I need to implement cross-domain access here to get a response from google api that returns a response in json format. But since access to the cross domain is not possible with xmlhttp, I cannot get an answer.
I have seen several posts suggesting use proxy.phpon the client side. But I do not use php, and I would like to know if there is a way to implement this using only jsp/javascript. Is there any special configuration in tomcat? Please help.
Here is what I am trying to do:
var url = "http://maps.googleapis.com/maps/api/directions/json?origin=26.849307092121,75.781290279188&destination=26.932491611988,75.805420139913&alternatives=true&sensor=false";
xmlhttp.open("GET",url,false);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
xmlhttp.send();
function AJAX_addShortestRoute() {
var response=xmlhttp.responseText;
alert(response);
}`
But the request is never processed because cross-domain access is not possible. Request for help
Thank you and respectfully Ginger.
source
share