Each time I get a JSON from an URL I face with this ERROR:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
I'm able to workaround it only through a chrome extension, but I still don't understand why I face this error simply calling an URL having this kind of JSON:
{"results" : [
{
"elevation" : 402.0888977050781,
"location" : {
"lat" : 11,
"lng" : 11
},
"resolution" : 152.7032318115234
}],"status" : "OK"}
It seems to me depending on HTML tags, but how generally could I do to simply parse the JSON above? Each method coming from Ajax or JQuery return me into this problem
The code I use to call the URL containing the JSON is a simple HTML having this script:
<script type="application/javascript">
function findAltitude() {
var lat = document.getElementById('lat').value;
var lon = document.getElementById('lon').value;
var url;
var json, data;
$.ajax({
dataType: "json",
url: url,
data: data,
success: function(data) {
alert(data.results[0].elevation);
}
});
}
</script>