I have an application that is running on my Google Maps. But today started giving the error:
XMLHttpRequest can not load http://maps.googleapis.com/maps/api/elevation/json?locations=-26.905, -49.05694 & sensor = true. Http://localhost:36452 Origin is not allowed by Access-Control-Allow-Origin.
The call of JQuery is this:
function alturaPonto(lat, lng, edt)
{
$.ajax({
type: "GET",
dataType: 'json',
crossDomain: true,
url: "http://maps.googleapis.com/maps/api/elevation/json?locations=" + lat + "," + lng + "&sensor=true",
success: function (msg) {
var retorno = msg.results[0].elevation;
edt.val(retorno);
}
});
}
Everything was ok, but now gives error. The result below works, and is called by a button. After that, or if I click on the map to create a point on the map and take the lift does not work. Why the difference between the two returns if the call is the same?
Request URL:http://maps.googleapis.com/maps/api/elevation/json?locations=-26.905,-49.05694&sensor=false
Request Method:GET
Status Code:200 OK (from cache)
Query String Parametersview sourceview URL encoded
locations:-26.905,-49.05694
sensor:false
Not working
Request URL:http://maps.googleapis.com/maps/api/elevation/json?locations=-26.899415168090034,-49.05200242996216&sensor=false
Request Headersview parsed
GET http://maps.googleapis.com/maps/api/elevation/json?locations=-26.899415168090034,-49.05200242996216&sensor=false HTTP/1.1
Accept: application/json, text/javascript, */*; q=0.01
Referer: http://localhost:36452/Posicionador
Origin: http://localhost:36452
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
Query String Parametersview sourceview URL encoded
locations:-26.899415168090034,-49.05200242996216
sensor:false
How to resolve this directly in JQuery? tks