簡體   English   中英

jQuery表單插件在IE中不起作用

[英]jQuery form plugin doesn't work in IE

我正在使用jQuery表單插件通過ajax上傳文件。 我已經測試了腳本,並且可以在除IE之外的所有瀏覽器中使用。似乎在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;
        }
    });
});

我該怎么辦? (感謝幫助。)

Internet Explorer 9及更低版本不支持XMLHttpRequest Level 2協議。 jQuery要求以異步方式上傳文件。 對於使用舊版IE瀏覽器的用戶,您必須使用iFrame或禁用上傳功能。

您可以使用條件注釋來測試IE的較早版本。 將以下內容添加到您的JavaScript中:

var div = document.createElement("div");
div.innerHTML = "<!--[if lte IE 9]><i></i><![endif]-->"; 

如果將變量“ div”設置為<i></i>值,則說明您正在處理的是舊版IE

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM