1.js传过来的字符串数据
2.php接收后转换为数组对象 $output = json_decode($cc);
结果不彻底,里面的是个字符串对象。不能使用。故而报错:
Cannot use object of type stdClass as array
解决方法:两种
1、使用 json_decode($d, true)。就是使json_decode 的第二个变量设置为 true。$output = json_decode($cc,true);就可以
2、json_decode($res) 返回的是一个对象, 不可以使用 $res['key'] 进行访问, 换成 $res->key 就可以了。