Answer the question
In order to leave comments, you need to log in
How to properly store current data?
Good afternoon. Please help me figure it out, I do the following:
Every 5 seconds I get the data of the usd/rub exchange rate.
setInterval( function () {
$.getJSON( 'https://query.yahooapis.com/v1/public/yql?q=select+*+from+yahoo.finance.xchange+where+pair+=+%22USDRUB%22&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=', function( data ) {
var price = data.query.results.rate.Rate;
console.log(price);
});
}, 5000 );
Answer the question
In order to leave comments, you need to log in
maybe like this
// глобальная переменная для курсов.
var data = [];
setInterval( function () {
$.getJSON( 'https://query.yahooapis.com/v1/public/yql?q=select+*+from+yahoo.finance.xchange+where+pair+=+%22USDRUB%22&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=', function( data ) {
var price = data.query.results.rate.Rate;
// проверяем что нужно тут
// делаем кеш
data = price;
console.log(price);
});
}, 5000 );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question