简体   繁体   English

jQuery的iframe的运输不适用于IE8中的jQuery文件上传

[英]jquery-iframe-transport not working for jquery file upload in IE8

I am using jQuery file upload to upload files in IE8. 我正在使用jQuery文件上传功能来上传IE8中的文件。 As this is an old non-HTML5 friendly browser, I am using jQuery Iframe Transport Plugin 1.8.2. 由于这是旧的非HTML5友好浏览器,因此我使用的是jQuery Iframe Transport Plugin 1.8.2。

The 'done' is not being called and Iframe content appears empty. 未完成“完成”操作,iframe内容显示为空。

CODE: 码:

$('#files').fileupload({
        dataType: 'json',
    url: "/FileUploads/Upload",
    type: 'PUT',
    forceIframeTransport: true,
    progressall: function (e, data) {
        var progress = parseInt(data.loaded / data.total * 100, 10);
        $('#progress .bar').css(
            'width',
            progress + '%'
        );
    },
add: function (e, data) {
            data.context = $('<button/>').text('Upload')
                .appendTo($('#FileUploadsDrop'))
                .click(function () {
                    data.context = $('<p/>').text('Uploading...'+$('#files').val()).replaceAll($(this));
                    data.submit();
                });
        },
        done: function ( e, data ) {
            var result = $( 'pre', data.result ).text();
                if(result != null && $.trim( result ) != '' ){
                $('#FileUploadsDrop').append( result );
}
    }

    });`

Here is the DOM situation: 这是DOM的情况: 在此处输入图片说明

In IE console, one cannot view json objects. 在IE控制台中,无法查看json对象。 So, I used JSON.stringify to check what was being returned by the server. 因此,我使用JSON.stringify来检查服务器返回的内容。 The browser appeared to be failing to parse the returned data and thus the JSON object was returning an error message to this effect. 浏览器似乎无法解析返回的数据,因此JSON对象为此返回了一条错误消息。

The reason I was getting this problem is due to the fact that the data being returned is in fact not json. 我遇到此问题的原因是由于以下事实:返回的数据实际上不是json。

So, to solve this problem, I removed dataType: 'json', 因此,为解决此问题,我删除了dataType: 'json',

Problem solved. 问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM