i got a simple question, i can't make the code to output only one result insted of multiple, i want to get only one first result, but it makes multiple because of each
looked up for stringify but couldnt 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'); } });thank you all for the help!
我有一个简单的问题,我不能让代码输出的结果只有一个相反的多,我想只有一个结果,但它使多由于each
抬头一看,stringify但不能设法让它正常工作
$('#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'); } });谢谢大家的帮助!