thinkphp封装方法添加跨域请求

function wang_json($data){
    //返回JSON数据格式到客户端,包含状态信息
    header('
        Content-Type:application/json;
        charset=utf-8
    ');
    header('Access-Control-Allow-Origin: *');//允许跨域
    echo json_encode($data);
}

 

posted @ 2018-08-10 15:54  =DLSS=webZT  阅读(382)  评论(0编辑  收藏  举报