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

  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. }  

猜你喜欢

转载自blog.csdn.net/mezheng/article/details/78538373
今日推荐