N
N
Nikolay Erofeev2015-07-18 16:43:40
JSON
Nikolay Erofeev, 2015-07-18 16:43:40

Why doesn't it take data from api weather?

Hello. There is a site openweathermap.org , which has api, make direct requests and take weather data. api.openweathermap.org/data/2.5/weather?q=London here is an example, but weather says undefined.

$.ajax({
    		url : "http://api.openweathermap.org/data/2.5/weather?q=London",
    		datatype:'json',
    		success : function(data) {
    			alert(data.weather.id);
    		}
    	});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Zuev, 2015-07-18
@Mackaybravo

Maybe because data.weather is an array?
Try this
. Why not immediately check through console.dir(data) what kind of data is coming?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question