I got a simple question, I can't make the code to output only one result instead of multiple, i want to get only one first result, but it makes multiple because of each
looked up for stringify but couldn't manage to make it work properly
$('#form').submit(function(){
var nick=$('#username').val();
if(nick.length > 0){
var url='http://api.worldoftanks.ru/2.0/account/list/?application_id=171745d21f7f98fd8878771da1000a31&search='+nick;
$.getJSON(url, function(json) {
$('#result').html('');
$.each(json.data, function(index, data) {
var id=data.id;
$('#result').append('<p> ID: ' + id+ '</p>');
});
});
}else{
alert('enter username');
}
});
No need of each
you can get first id using
json.data[0].id