Answer the question
In order to leave comments, you need to log in
How to display a message on the screen instead of a dialog box (alert)?
How instead of a dialog box (alert) to display a message on the screen through <а id="test">а>?
Working example:
$.getJSON('https://minecraftpocket-servers.com/api/?object=servers&element=voters&key=ruc7ov3m2v4w7fqeq6np8fhivep48w', function(data) {
$('#test').html(data.voters.length);
});
$.getJSON('https://minecraftpocket-servers.com/api/?object=servers&element=voters&key=ruc7ov3m2v4w7fqeq6np8fhivep48w', function(data) {
var votes = 0;
for(var i=0; i<data.voters.length; i++){
votes += JSON.parse(data.voters[i].votes)
}
alert(['голосов: ' + votes, ' проголосовавших: ' + data.voters.length]);
});
Answer the question
In order to leave comments, you need to log in
$.getJSON('https://minecraftpocket-servers.com/api/?object=servers&element=voters&key=ruc7ov3m2v4w7fqeq6np8fhivep48w', function(data) {
var votes = 0;
for(var i=0; i<data.voters.length; i++){
votes += JSON.parse(data.voters[i].votes)
}
$('#someDivId').html('голосов: ' + votes + ' проголосовавших: ' + data.voters.length);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question