I am developing a GIS Map Java web application using jsp, javascript/ajax/jQuery which is deployed in tomcat server. I need to implement cross-domain access here to get response from google api which return response in json format. But since cross domain access is not possible with xmlhttp, I cant get a response.
I have seen some posts suggesting the use of proxy.php in client side. But I am not using php and I would like to know if there is anyway to implement this using jsp/javascript alone. Is there any special configuration to be set in tomcat?? Kindly help.
Here is what i try 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() {
// if(xmlhttp.readyState == 4) {
var response=xmlhttp.responseText;
// document.write(response);
alert(response);
}`
But the request is never processed, since cross-domain access is not possible. Kindly help
Thanks and Regards Ginger.