javascript - 这种后台获取的数据如何分别取出id
大家讲道理
大家讲道理 2017-04-11 12:54:10
0
4
259

{"0":

{"id":1,"title":"1","content":"<p>1asdfasdf</p>","publisher":"3asdf ","views":0,"create_time":1490173181,"create_user":1,"status":0},

"1":{"id":2,"title":"2","content":"<p>asdfasdf</p>","publisher":"asdfadsf","views":0,"create_time":1490173186,"create_user":1,"status":0},
"2":{"id":3,"title":"3","content":"<p>2</p>","publisher":"3","views":0,"create_time":1490250129,"create_user":1,"status":0},"success":true}

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

모든 응답(4)
巴扎黑

var data = {"0":{"id":1,"title":"1","content":"<p>1asdfasdf</p>","publisher":"3asdf ","views":0,"create_time":1490173181,"create_user":1,"status":0},"1":{"id":2,"title":"2","content":"<p>asdfasdf</p>","publisher":"asdfadsf","views":0,"create_time":1490173186,"create_user":1,"status":0},"2":{"id":3,"title":"3","content":"<p>2</p>","publisher":"3","views":0,"create_time":1490250129,"create_user":1,"status":0},"success":true}}

for(var i in data){

console.log(data[i].id);

}

洪涛
var jStr = {"0":{"id":1,"title":"1","content":"<p>1asdfasdf</p>","publisher":"3asdf ","views":0,"create_time":1490173181,"create_user":1,"status":0},"1":{"id":2,"title":"2","content":"<p>asdfasdf</p>","publisher":"asdfadsf","views":0,"create_time":1490173186,"create_user":1,"status":0},"2":{"id":3,"title":"3","content":"<p>2</p>","publisher":"3","views":0,"create_time":1490250129,"create_user":1,"status":0},"success":true}
    for(var i in jStr){
        if(jStr[i].id){
            console.log(jStr[i].id)
        }
    }
阿神
$.get('a.json',function (data,status) {
    console.log(data)
    for(var i=0;i<data.length;i++){
       console.log(data[i])
    }
})
左手右手慢动作

例如:

var arr = {"1":{"id":1,"name":"test"},"2":{"id":2,"name":"测试"}};
  $.each(arr,function(idx,item){    
   //输出
   alert(item.id+","+item.name);
})
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!