注:非必要情况。可直接在后台操作数据,不适用ajax更简单

 ($sn_arr = $_COOKIE;)   ---------------获取所有cookie进行筛选操作 

1.js(页面加载0.5ms后执行函数)

 $(function(){
        setTimeout(function () {
            $.ajax({
                url:"/supplierbuyer/order/getCookie",
                data:{
                },
                type:"POST",
                dataType:"JSON",
                success:function(data){
                    if(data.status==true){
                        //处理cookie的数据
                        var cookie_content = data['sn_arr'];
                        $.each(cookie_content, function(index, item){
                            if (index.startsWith("order_sn_")) {
                                var order_sn = index.substr(9);
                                $('.'+order_sn).text('');
                                $('.'+order_sn).parent().prev().css("background","");
                            }
                        });
                    }else{
                        console.log(data);
                        return false;
                    }
                }
            });
        }, 0.5);

    });

2.php

 /**
     * 获取cookie
     */
    public function getCookie()
    {
        $sn_arr = $_COOKIE;
        if ($sn_arr) {
            $data['status'] = true;
            $data['sn_arr'] = $sn_arr;
            $data['msg'] = 'ok';
        } else {
            $data['status'] = false;
            $data['sn_arr'] = '';
            $data['msg'] = '网络错误,请稍后重试~';
        }
        echo json_encode($data);
        exit();
    }

 

相关文章:

  • 2021-12-31
  • 2021-07-10
  • 2021-05-05
  • 2021-12-23
  • 2021-12-28
  • 2021-12-19
  • 2021-05-26
  • 2021-08-19
猜你喜欢
  • 2021-11-20
  • 2021-12-04
  • 2022-01-08
  • 2021-04-19
  • 2021-12-04
  • 2021-11-19
  • 2021-11-17
  • 2021-11-21
相关资源
相似解决方案