我使用这插件让用户通过ajax上传图片。
为了创建上传器并触发post,使用了以下jQuery函数:
function createUploader() {
var uploader = new qq.FileUploader({
element: document.getElementById('file-uploader'),
allowedExtensions: ['pdf'],
multiple: false,
action: '@Url.Action("AjaxUpload", "Upload")',
onComplete: function(id, fileName, responseJSON){
window.location.href = responseJSON.message;
}
});
}在responseJSON.message中,我返回文件上传的路径(实际上是转换的),我正在使用window.location.href来强制浏览器显示该文件的用户下载框。
这在FF和Chrome上很好,但在IE上却是这样的:
Do you want to open or save AjaxUpload from localhost?
如果您按open,而不是从指定的位置获取文件,实际上您将得到一个包含responseJSON消息的文件。
有谁能给我提供这个问题的线索的jQuery大师?
UPDATE:我能确认的是,这个问题不是window.location.href = responseJSON.message;的问题,因为即使我删除了这一行,并将alert('something')放入相同的问题occurs...so,而不是解析onComplete,IE也尝试打开JSON响应.
发布于 2012-05-30 20:15:53
试一试
return Json(new { Data = new { message = outputFilePathResponse } }, "text/html");参考资料:IE试图在ASP中下载JSON。3
https://stackoverflow.com/questions/10822906
复制相似问题