4
我在我的MVC项目中使用jQuery表单插件进行图像上传。用Jquery表单插件上传图像不工作在IE8
的图片上传完美的作品在Chrome和Firefox,但是当涉及到IE 8
不喜欢Chrome浏览器,而不是返回稍后所消耗的JSON数据提交后回调,在IE 8则返回一个txt文件并询问你是否要下载。而在txt文件中,它是json数据。
无法弄清楚我做错了什么,有什么想法?
在此先感谢。
代码被放置在一个分离式的js文件: upload.js
(function ($) {
ImageUploader = function (o) {
var options = {
success: showResponse, // post-submit callback
url: "/Image/ImageUpload", // override for form's 'action' attribute
type: "post", // 'get' or 'post', override for form's 'method' attribute
dataType: 'json', // 'xml', 'script', or 'json' (expected server response type)
clearForm: true // clear all form fields after successful submit
};
o.ajaxForm(options);
$("input#file").change(function() {
o.submit();
});
// post-submit callback
function showResponse(responseText, statusText, xhr, $form) {
....
}
};
})(jQuery);
在页面视图:
$(document).ready(function() {
ImageUploader($("#ajaxUploadForm"));
});
我想你在ajax中指定Accept头参数为text/javascript(现在我可以记得)。这不是IE 8的错误,但功能:)内容类型告诉服务器你发送了什么,但你需要告诉它你期望的回报 – 2011-07-31 21:46:23