var json = "{'id':1,'options':[
  {'id':11,'options':[]},
    {'id':111,'options':[
      {'id':1111,'options':[]}
    ]}
  ]}";现在我想找到id为111的信息,如何获取呀?
怎样来根据id去json中取值呀?

解决方案 »

  1.   


    function getOut(){
    var s='';
    $.ajax({
    type:'get',//请求方式
    url:'out.jsp', // AJAX HTTP请求接口
    data:'',//提交到服务器接口的参数 比如'{cid:0405}',结果为out.jsp?cid=0405格式
    dataType:'json',//请求类型为json, 更多见jquery doc文档 
    timeout:7000,//请求超时后停止请求
    success: function(d){
    $.each(d,function(i){
    s+=('<p>'+d[i].options+'</p><hr/>');//再循环两次就可以了
    });
    $('#out').html(s);}});
    }