js遍历ajax回调函数返回值中的object对象

function printObject(obj) {  
    //obj = {"cid":"C0","ctext":"区县"};  
    var temp = "";  
    for (var i in obj) { //用javascript的for/in循环遍历对象的属性  
        temp += i + ":" + obj[i] + "\n";  
    }  
    //alert(obj);  //结果:[object Object]  
    //console.log(obj);  //使用firebug查看结果  
    alert(temp);   //结果:cid:C0 \n ctext:区县  
}  
---------------------
作者:mezheng
来源:CSDN
原文:https://blog.csdn.net/mezheng/article/details/78538373
版权声明:本文为博主原创文章,转载请附上博文链接!

posted on 2018-10-19 20:24  asdyzh  阅读(752)  评论(0编辑  收藏  举报

导航