JQuery-File-Upload error: Uncaught TypeError: Obje

2020-07-02 11:04发布

问题:

I'm trying to use the jQuery-File-Upload plugin. But I have a problem when actually trying to invoke the function. Somewhere in my code, I'll call $(fubar).fileupload, and get Uncaught TypeError: Object #<Object> has no method '_on' jquery.fileupload.js:977. Now this is happening after the page and all js scripts have been loaded.

A) A similar error is discussed in the tool's boards. I tried the technique of including jquery.fileupload.js just after the dom loads. I tried the technique, with something like below.

  <script src='/static/presentation/js/lib/jquery.fileupload.js'></script>
  <script src='/static/presentation/js/lib/jquery.iframe-transport.js'></script>
</body>

But when loading the page, I get another error Uncaught Error: Mismatched anonymous define() module: function ($) {... .

B) On documentReady, I even tried dynamically generating and including the script tags, in head. But I get the same error Uncaught Error: Mismatched anonymous define() module: function ($) {... .

I'm using jquery-file-upload with requirejs. I only bring that up I tested out the library and got it working with a plain jane static site. Just the basic js library files. So I don't know what's causing this. But it doesn't seem to be DOM related.

Any help is appreciated.

回答1:

Ok, I just figured it out. I simply need to include jquery.fileupload.js after jquery.ui.widget.js and jquery.iframe-transport.js . At least I know for future reference.

<script src='/static/presentation/js/lib/jquery.ui.widget.js'></script>
<script src='/static/presentation/js/lib/jquery.iframe-transport.js'></script>
<script src='/static/presentation/js/lib/jquery.fileupload.js'></script>


回答2:

Make sure you are running complementary versions of jQuery and jQuery UI, and only one copy of jQuery. I realized I had jquery-rails running at 1.10 and a local jQuery 1.11 file, and removing the latter and upgrading the former did the trick.



回答3:

With the newest version blue imp I just change jquery.ui.widget.js with jquery-ui-1.9.2.custom.min.js and it work well. Hope this help someone stuck with this.