您现在的位置:首页 >> 前端 >> 内容

解决IE下返回json数据提示文件保存到问题解决

时间:2018/2/26 14:14:51 点击:

  核心提示:在IE9,10,11下,当服务器端返回数据格式为json,且明确设置Content-Type为application/json;charset=utf-8时,会提示文件下载。如图所示:解决方法//发送...

在IE9,10,11下,当服务器端返回数据格式为json,且明确设置Content-Type为”application/json;charset=utf-8“时,会提示文件下载。如图所示:

解决IE下返回json数据提示文件保存到问题解决

解决方法

    //发送的是JSON
    public static void renderJson(HttpServletResponse response,String text){
        render(response, "application/json;charset=UTF-8", text);
    }
    改为
        //发送text
    public static void renderText(HttpServletResponse response,String text){
        render(response, "text/plain;charset=UTF-8", text);
    }

//前段接收
            success : function(result) {  
        //将text拼接为json
                    var result = eval('(' + result + ')');  
                    if (result.message== 'ok') {

                    }else{

                    }
                }  

Tags:解决 决I IE E下 
作者:网络 来源:zhou920786