thinkphp 查表返回的数组,js解析有UNICode编码,解决办法

public function getDeviceMsg(){
            $allDevicesMsg = M("newdevicesstatus")->getField("status",true);
            $allDevicesMsg2 = array();
//             var_dump($allDevicesMsg);
            for($i=0;$i<sizeof($allDevicesMsg);$i++){
                $allDevicesMsg2[$i] = urlencode($allDevicesMsg[$i]);
            }
//             $this->ajaxReturn( urlencode($allDevicesMsg)); // 不能对整个数组urlencode

$this->ajaxReturn(json_encode(array('status'=>'1', 'errMsg'=>$allDevicesMsg2))); }
$.ajax({
                                    url:"getDeviceMsg",//这里指向的就不再是页面了,而是一个方法。
                                    data:{},
                                    type:"POST",
                                    dataType:"JSON",//和控制器转换对应
                                    async:false,
                                    success: function(data){
                                        alert(decodeURIComponent(data));//这里要用索引,使用eq读取不出来数据。
                                        cs = objipt_exist2.childNodes
                                        for(i=0;i<cs.length;i++)
                                        {
                                           cs[i].append(",状态"+data);             
                                        }          
                                    },
                                    error : function(XMLHttpRequest, textStatus, errorThrown) {
                                        alert(XMLHttpRequest.status + ",xddwd" + textStatus);
                                    }
                                });             
原文地址:https://www.cnblogs.com/Jackie-zhang/p/10140680.html