I am trying to use a weather plugin: http://jsfiddle.net/fleeting/a4hbL/light/
which asks for either zipcode or woeid. I don't want to hard wire the zipcode there. I would rather zip code is dynamic so people spread over various locations can use the site, with the plugin working for their location. I am trying to auto detect their location using their IP and a webservice that geolocates based on IP.
$.getJSON('http://freegeoip.net/json/', function(data) {
var items = [];
var zip = data["zipcode"];
});
I need to pass the zip to the plugin below: $.simpleWeather({ zipcode: 'zip', ... });
There is no below, $.getJSON
is async, so you do it in the success handler :
$.getJSON('http://freegeoip.net/json/', function(data) {
$.simpleWeather({ zipcode: data.zipcode });
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.