How to use certain parts of a JSON and put it in an alert (Plain Javascript) -


i bookmarklet when click on it, goes json , grabs "temp" there, , puts alert tell me weather click of button. there way it? or have use different api?

this i've far:

function insertreply(content) {     document.getelementbyid('output').innerhtml = content; }  var script = document.createelement('script'); script.src = 'http://api.openweathermap.org/data/2.5/find?q=australia,wa&mode=json'; document.body.appendchild(script); 

sure. first, realize that api seems support jsonp. is, if provide callback parameter, wrap response <callback>(...) <callback> value of callback parameter. means use url:

http://api.openweathermap.org/data/2.5/find?q=australia,wa&mode=json&callback=insertreply 

and insertreply function provided appropriate object. then, if want grab temp out of it, use content object:

document.getelementbyid('output').innerhtml = content.list[0].main.temp; 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -