我希望 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);
}
});
在所有其他浏览器中,这会触发获取数据的调用。然而,在 IE8 中,这会导致弹出一个对话框,询问用户是否要下载文件。它看起来像这样:
我看到了this post但无法正确更改 ContentType。
如何在 IE8 中做同样的事情而不影响其他浏览器?谢谢你的想法!
最佳答案
我想这与 MIME type 有关.
您必须告诉浏览器将其视为文本/html。然后它不会尝试下载它,而是将其显示为文本。
为此,您可以在 header 中发送 Content-type = "text/html"
。
关于javascript - IE8 jquery json响应触发下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19717756/