zoukankan      html  css  js  c++  java
  • 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);
                                        }
                                    });             
  • 相关阅读:
    BPF and eBPF linux
    o-sync-and-o-direct
    linux performance test
    iostat
    MYSQL IO innodb-buffer-pool
    MYSQL file types redo log
    read pread write pwrite open
    CORE DUMP
    linux kernel的中断子系统 softirq
    linux KERNEL 问题
  • 原文地址:https://www.cnblogs.com/Jackie-zhang/p/10140680.html
Copyright © 2011-2022 走看看