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.