Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3878452
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:36:52+00:00 2026-05-19T22:36:52+00:00

I’m using the Plupload file uploader within a form. I want to customize it

  • 0

I’m using the Plupload file uploader within a form. I want to customize it such that when the form is submitted, i.e. when the “Submit” button is clicked, the first thing that happens is the file uploading, followed by the submission of the form.

From what I can tell, and I might be wrong with this, but it seems that the call uploader.start() is an asynchronous function call. So at the moment, the uploading will begin and the form will submit before the files are uploaded. The problem is that I don’t have control over this function call.

I’ve recently read about the new release of jQuery 1.5 and the new Deferred Object and it seems like this has the potential to help me solve this problem. Is there a way to wait for the asynchronous function call to finish its work and then continue the execution of the code after the call. So I’m looking for something like the following pseudocode…

var uploader = $('#plupload_container').pluploadQueue();

$('#submitButton').click(function() {

   // if there are files to be uploaded, do it
   if (uploader.files.length > 0) {

      // make the call and wait for the uploader to finish
      uploader.start();
      while ( the uploading is not done ) {
         wait for the uploader to finish
      }

      // continue with submission
   }
});

Is there a way to “wait” for uploader.start() to finish, essentially putting a pause on the click event handler, so that all the files can be uploaded first and then the rest of the click event handler can finish executing? I’ve tried the following but “done” is printed before the files are done uploading…

$.when(uploader.start()).then(function () {
   console.log("done")
});

Another useful piece of information… I can bind certain events to this uploader object instance, such as “UploadProgress” or “UploadComplete”. Can I use the Deferred Object somehow to catch when the “UploadComplete” event fires, for example? Is there an AJAX-y way to do this?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:36:52+00:00Added an answer on May 19, 2026 at 10:36 pm

    Your problem is that although uploader.start does something asynchronous for the code to work, uploader.start has to return a jquery $.deferred object.

    From the latest source on your uploader plugin:

    /**
     * Starts uploading the queued files.
     *
     * @method start
     */
    start : function() {
        if (this.state != plupload.STARTED) {
            this.state = plupload.STARTED;
            this.trigger("StateChanged");
            uploadNext.call(this);
        }
    },
    

    So it doesn’t return a deferred object. Instead in the uploadNext function there is this line of code:

    this.trigger("UploadComplete", files);

    So we simply have to bind to your uploader,

    uploader.bind("UploadComplete", function(files) {
        // your code
    });
    

    I’ve never used that plugin but this should work. Good luck.

    If you must use deferreds then you can always something like this pseudocode:

    var uploader = $('#plupload_container').pluploadQueue();
    var def = $.Deferred();
    uploader.bind("UploadComplete", function(files) {
        def.resolve(files);
    });
    $('#submitButton').click(function() {
       if (uploader.files.length > 0) {
          uploader.start();
    
          def.done(function(files) {
              def = $.Deferred(); // reset the deferred object.
              // rest of your click handler.
          });
    
       }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
In order to apply a triggered animation to all ToolTip s in my app,
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.