运行后 为什么提示的结果是[object object],[object object] 而不是具体的数据呢?
这个结果应该是这样才对[{title: "3333333333333"}, {title: "3333333333333"}]
然后我又试了一下alert(obj.title) 这样提示undefined 这是为什么?
<code>$res=$xiao->field("title")->select();
$this->ajaxReturn($res);
ajax("{:U('zhuye/zhuye')}",oV1,function(str){
var obj = eval("("+str+")");
alert(obj);
});</code>运行后 为什么提示的结果是[object object],[object object] 而不是具体的数据呢?
这个结果应该是这样才对[{title: "3333333333333"}, {title: "3333333333333"}]
然后我又试了一下alert(obj.title) 这样提示undefined 这是为什么?
<code>$res=$xiao->field("title")->select();
$this->ajaxReturn($res);
ajax("{:U('zhuye/zhuye')}",oV1,function(str){
var obj = eval("("+str+")");
alert(obj);
});</code>
用jquery解决你的问题,具体看文档吧
obj是两个Object的Array 不是Object
试试alert(obj[0].title); alert(obj[1].title);
立即学习“Java免费学习笔记(深入)”;
试试. 出来的应该就是 你说的那种数组形式.
<code>var obj = JSON.parse(str) alert(obj);</code>
加一个返回数据类型就可以了,dataType:json
打印出来看。。。。
应该是
<code> alert(obj[0].title); </code>
你的数据已经是Object了。你在eval或JSON.prase时,调用的是 obj.toString();
你去看看JavaScript 字面量对象和json的区别就知道是什么问题了。
返回类型不是json格式吧
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号