json xhr响应打开一个下载文件弹出窗口 [英] json xhr response opens a download file popup window

查看:118
本文介绍了json xhr响应打开一个下载文件弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我们的一个ajax请求(使用.json响应),我们的一些客户端抱怨他们看到一个文件下载提示,要求用户下载.json响应。我很为难,因为考虑到这是一个xhr的回应,这绝对不会发生。有没有人看到这个?

For one of our ajax request (with a .json response) some of our clients have complained that they are seeing a "File Download" prompt asking the user to download the .json response. I am baffled because considering that this is an xhr response, this should never happen. Has anyone seen this?

谢谢

推荐答案

使用ASP MVC并且具有与IE相同的问题,在返回您的响应时使用此功能:

For people who are using ASP MVC and have the same problem with IE, use this when returning your response:

return Json(result, "text/plain");

编辑:标准类型是:application / json,但不适用于IE。使用text / html是危险的。

the standard type is: "application/json", but does not work with IE. using text/html is dangerous.

这篇关于json xhr响应打开一个下载文件弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆