jQuery File Upload doesn't work in IE9 when co

2019-05-23 08:00发布

问题:

My code uses Backbone with Requirejs and jQuery File Upload and works perfectly in IE 9 when I access the development code directly (without building). As soon as I build it something goes wrong and the request is sent empty to the server.

The only difference I see in the request (using Network capturing in IE9) is that the one that works when I click in the upload button, the Initiator is click, and for the one that fails, the initiator is JS Library XMLHttpRequest.

So there must be something making the event change when the code gets compressed, but I have no idea how to get closer to the root of the problem.

Any ideas?

回答1:

Are you requiring the iFrame Transport plugin?

I am using jQuery File Upload with Requirejs, and have not seen this issue. Without seeing some code, it is hard to say what is tripping up your application. I suggest updating your question with some relevant code. In the meantime, here is what is working for me.

main.js

require.config({
    appDir: '../',
    baseUrl: 'js/',
    paths: {
        underscore: '../vendor/lodash.underscore',
        backbone: '../vendor/backbone',
        'jquery.fileupload': '../vendor/jquery-file-upload/js/jquery.fileupload',
        'jquery.iframe-transport': '../vendor/jquery-file-upload/js/jquery.iframe-transport',
        'jquery.ui.widget': '../vendor/jquery-file-upload/js/jquery.ui.widget'
    },
    shim: {
        underscore: {
            exports: '_'
        },
        backbone: {
            deps: ['underscore', 'jquery'],
            exports: 'Backbone'
        }
    }
});

And in the page that houses the upload control:

UploadPage.js

define([
    'views/Base',
    'jquery.iframe-transport',
    'jquery.fileupload'
], function(BaseView) {
    return BaseView.extend({
        // Do cool stuff
    });
});