javascript - No response from getJSON -


i'm trying build small service using apache cordova , javascript, typically i'm trying avoid js , use ready solutions, question quite unique.

my app simple, checks current coordinates (i'm using geolocation api, works well) , looks coordinates using uk-postcodes.com api , looks matching postal code , app should display it. reason cannot make query uk-postcodes. current code looks that:

var url = "http://uk-postcodes.com/latlng/" + position.coords.latitude + "," + position.coords.longitude + ".json?callback=json";  $.getjson(url, function (json) {     console.log(json.postcode); }); 

i able display variable url , working fine that's not source of problem. looks (example) http://uk-postcodes.com/latlng/51.5000,0.1167.json , works fine.

my problem sits somewhere inside .getjson code, i'm not experienced enough solve , i'm not getting errors in console.

you're getting error because you're running request different not-cors-enabled server page. you'll need use cors proxy - example, https://crossorigin.me.

just add https://crossorigin.me/ before you're url , you'll go:

url = 'https://crossorigin.me/' + url; 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -