我使用jQuery表单插件通过ajax上传文件。我已经测试了脚本,它在所有浏览器上都能工作,除了IE.It,在IE中似乎什么都没有发生(事件&.)。我工作了几个小时,还是没有运气。
PHP:
echo $this->input->post('name');//this is a debuging statement which shows the data sent by client
JS:
$("input[type=file]").on('change',function(){
$(this).parents('.fileinput-wrapper').find('.fileinput-preview').css('background','url(http://localhost/project/assets/images/ajax-loader.GIF) no-repeat center center');
var selectedElement = this;
var name = $(this).attr('name').toString();
$('#upload').ajaxSubmit({
//dataType:'json',
data: {name:name},
success: function(data) {
$(selectedElement).parents('.fileinput-wrapper').find('.fileinput-preview').css('background',"url('http://localhost/project/assets/images/loading.png') no-repeat center center");
return false;
},
error : function(xhr) {
alert(xhr.responseText);
return false;
}
});
});
我该怎么办?(谢谢你的帮助)
发布于 2013-11-27 13:47:52
Internet 9及以下版本不支持XMLHttpRequest级别2协议。这是jQuery异步上传文件所必需的。您将不得不使用iFrame或禁用使用传统IE浏览器的用户的上载功能。
您可以使用条件注释来测试早期版本的IE。在JavaScript中添加以下内容:
var div = document.createElement("div");
div.innerHTML = "<!--[if lte IE 9]><i></i><![endif]-->";
如果变量"div“是用<i></i>
值设置的,那么您处理的是一个旧版本的IE
https://stackoverflow.com/questions/20253308
复制相似问题