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);
                                        }
                                    });             
  • 相关阅读:
    攻防世界pwn高手区——pwn1
    攻防世界misc——János-the-Ripper
    攻防世界逆向——game
    PWN——ret2dl_resolve
    谈一些想法
    python网络编程(一)
    pwnable.kr之unlink
    堆的数据结构探究
    记一次GKCTF之旅
    socket笔记
  • 原文地址:https://www.cnblogs.com/Jackie-zhang/p/10140680.html
Copyright © 2011-2022 走看看