I'm using an API that needs a URL like this one:
var URL_PARADAS = 'http://datos.santander.es/api/rest/datasets/paradas_bus.json';
function paradas(lat, lon, dist) {
console.log(lat);
console.log(lon);
var lat_min = lat - dist;
var lat_max = lat + dist;
var lon_min = lon - dist;
var lon_max = lon + dist;
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open('GET', URL_PARADAS + '?query=wgs84_pos\:lat:{' + lat_min + '%20TO%20' + lat_max + '}'
+ '%20AND%20'
+ 'wgs84_pos\:long:{' + lon_max + '%20TO%20' + lon_min + '}',
false);
xmlHttp.send(null);
var result = JSON.parse(xmlHttp.responseText);
console.log(result);
}
Without slash: on the URL it won't work, if I use xmlHttp.open(url) it's replaced by : so it doesn't receive anything.
Edit: I needed to replace \ to "slash" on this question due to bad output.