Answer the question
In order to leave comments, you need to log in
How to see returned json?
Good day!
There is such a code
// запись в переменную :
var my_city="London";
var my_key="pybn53rvr3sp7s79wy4jryma";
var no_of_days=5;
// строим запрос:
var uri="http://api.worldweatheronline.com/free/v1/weather.ashx?q="+my_city+"&format=json&num_of_days="+no_of_days+"&key="+my_key+"";
// uri-encode it to prevent errors :
uri=encodeURI(uri);
// подключаем ссылку:
jQuery.get(uri,function(r){},"json");
alert( r() );
does not give results, parse and display json in DIV. I'm not very familiar with js. Pliz, give links to an article on the topic or help with a solution. Thanks in advance!
Answer the question
In order to leave comments, you need to log in
console.log(r);
In the console, look at the result,
but alert() does not work for you because you need to pass the variable r
And yet, check whether the response from the server really comes, if there is no response, then the function simply will not be executed.
Write an error-handler for the request and look there.
Also, check on the worldweatheronline website whether it is really possible to make such requests to them (there may be problems with Access-Control-Allow-Origin).
Try to watch the server responses directly on the network interaction tab (in the built-in browser developer tools, DevTools, FireBug, etc.)
And you can conveniently study a large piece (so as not to sculpt a bicycle), for example here: jsonviewer.stack.hu
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question