JSON

cant stringify json data, single output intead of multiple

字号+ 作者:H5之家 来源:H5之家 2015-11-21 11:57 我要评论( )

i got a simple question, i cant make the code to output only one result insted of multiple, i want to get only one first result, but it makes multiple

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'); } });

谢谢大家的帮助!

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • php CI 实战教程:[5]用curl获取json并解析

    php CI 实战教程:[5]用curl获取json并解析

    2016-02-26 17:00

  •  JSON入门级学习总结-JSON数据结构

    JSON入门级学习总结-JSON数据结构

    2016-02-25 11:05

  • Android解析Json速度最快的库:json

    Android解析Json速度最快的库:json

    2016-02-13 18:00

  • JavaScript转换与解析JSON方法实例详解第1/2页

    JavaScript转换与解析JSON方法实例详解第1/2页

    2016-02-10 21:25

网友点评
/