[英]IE8 jquery json response triggers download
I want IE8 to work with the following piece of jquery that returns ajax request as json: 我希望IE8使用以下可返回ajax请求作为json的jquery:
$.ajax({
url: formAction,
type: 'post',
dataType: 'json',
data: form,
success: function(data) {
closeBlocker();
if (data.count != 0) {
$('#divid').toggle('slow');
} else {
$("#anotherdiv").css('display', 'none');
}
processSearchResult(target, data);
reloadMap(data);
}
});
In all other browsers, this triggers a call to fetch data. 在所有其他浏览器中,这会触发调用以获取数据。 In IE8, however, this results in a dialog box popping up that asks users if they want to download a file.
但是,在IE8中,这会弹出一个对话框,询问用户是否要下载文件。 It looks like this:
看起来像这样:
I saw this post but havent been able to properly change the ContentType. 我看到了这篇文章,但还没有能够正确更改ContentType。
How can I do the same thing in IE8 without affecting other browsers? 如何在IE8中做同样的事情而不影响其他浏览器? Thanks for your ideas!
感谢您的想法!
I guess it's related to MIME type . 我想这与MIME类型有关 。
You have to tell browser to treat it as text/html. 您必须告诉浏览器将其视为text / html。 Then it will not try to download it, and will display it as text instead.
然后它将不会尝试下载它,而是将其显示为文本。
For this you can send Content-type = "text/html"
in header. 为此,您可以在标头中发送
Content-type = "text/html"
。
Probably this will solve your issue 也许这可以解决您的问题
IE8 treats json response as file and tries to download it IE8将json响应视为文件并尝试下载它
I had the same problem when I try to do ajax calls from other domain, I introduced proxy with my URL and it got fixed. 当我尝试从其他域进行Ajax调用时,我遇到了同样的问题,我在URL中引入了proxy,它得到了修复。
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.