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

来源:互联网 发布:广东广播开放大学网络 编辑:程序博客网 时间:2024/05/16 13:42
  1. function printObject(obj) {  
  2.     //obj = {"cid":"C0","ctext":"区县"};  
  3.     var temp = "";  
  4.     for (var i in obj) { //用javascript的for/in循环遍历对象的属性  
  5.         temp += i + ":" + obj[i] + "\n";  
  6.     }  
  7.     //alert(obj);  //结果:[object Object]  
  8.     //console.log(obj);  //使用firebug查看结果  
  9.     alert(temp);   //结果:cid:C0 \n ctext:区县  
  10. }  
原创粉丝点击