Answer the question
In order to leave comments, you need to log in
Why doesn't jQuery work in getJSON?
I actually use the Jquery function - $.getJSON
Inside the function, for some reason, it does not see other jquery commands, although they do it everywhere on the Internet. I'm not a JS guru so see what's wrong here:
$(document).ready(function () {
$.getJSON('curs_valut.json', function (data) {
for (var i = 0; i < data.length; i++) {
if (data[i].name == "USD") $('#usd').innerText = 'USD ' + data[i].value.toFixed(2);
if (data[i].name == "RUB") $('#rub').innerText = 'RUB ' + data[i].value.toFixed(2);
}
});
});
$('#usd').innerText
, document.getElementById("usd").innerText
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question