Answer the question
In order to leave comments, you need to log in
js code not working?
Good day.
there is a json file
{
"artist":"ALAN WALKER",
"title":"Ghost"
}
var myVar = setInterval(function(){ nowtrack() }, 1000);
function nowtrack() {
$(document).ready(function(){
$.getJSON('https://site.ru/json.txt', {}, function(json){
$('#nowtrack').html('');
$('#nowtrack').append('<div class="artist">' + json.artist + '</div >')
$('#nowtrack').append('<div class="title">' + json.title + '</div >')
});
});
}
Answer the question
In order to leave comments, you need to log in
this code works
var myVar = setInterval(function() {
nowtrack()
}, 1000);
function nowtrack() {
$(document).ready(function() {
$.getJSON('https://www.site.ru/xml/json.txt', {}, function(json) {
$('#nowtrack').html('');
$('#nowtrack').append('<div class="artist">' + json.artist + '</div >')
$('#nowtrack').append('<div class="title">' + json.title + '</div >')
$('#nowtrack').append('<img src="' + json.image600 + '" style="width: 250px;";>')
});
});
}
jQuery.3.3.1<div id="nowtrack">
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question