javascript alert()在IE中不起作用

时间:2013-11-29 09:29:29

标签: javascript jquery ajax internet-explorer

我有一个Ajax请求,在错误情况下会警告从服务器返回的消息。这适用于除IE之外的所有浏览器。它显示一个空警报框。

JS:

$(document).ready(function() {
    $("input[name!='photo_1']").parents('.fileinput-wrapper').find(".label").remove();

    $("input[type=file]").on('change',function(){
        $(this).parents('label').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},
            beforeSubmit:function(){
                $(selectedElement).parents('label').find('input[type=file]').attr('disabled','disabled');
            },
            success: function(data) {
                $(selectedElement).parents('label').find('.fileinput-preview').css('background',"url('http://localhost/project/assets/images/loading.png') no-repeat center center");
                $.each(data, function(index, item) {
                    $("input[name=" + index + "]").parents('label').find('img').remove();
                    $("input[name=" + index + "]").parents('label').find('.fileinput-preview').append("<img src='http://localhost/project/uploads/" + item.NAME +"' width='190px' height='" + Math.floor(190/(item.WIDTH/item.HEIGHT)) + "px' />");
                    $("input[name=" + index + "]").parents('label').find('.thumbnail').css('height','');
                    $("input[name=" + index + "]").parents('label').find('.thumbnail').css('min-height',Math.floor(190/(item.WIDTH/item.HEIGHT)).toString()+"px");
                });
                $(selectedElement).parents('label').find('input[type=file]').removeAttr('disabled');
                return false;
            },
            error : function(xhr) {
                alert(xhr.responseText);
                $(selectedElement).parents('label').find('.fileinput-preview').css('background',"none");
                $(selectedElement).parents('label').find('.fileinput-preview').css('background',"url('http://localhost/project/assets/images/upload_a_photo.png') no-repeat center center");
                return false;
            }
        });
    });
});

0 个答案:

没有答案