Topic: Submit gets done twice?

Hi all,

I have the following problem.
My form consists of more then just the Plupload part, and also has some normal text inputs, etc. Therefor, a proper submit of the form is crucial.
When trying the demo code on the "Examples" page, my form gets submitted TWICE. Debugging it gave me the culprit: the code on line 54:

if (uploader.total.uploaded == uploader.files.length)

is being run twice. Therefor, the form gets submitted twice. I've replaced the code

$('form').submit();

with a simple

alert()

, which gives me 2 alerts.
Anyone has the same problem? Is this a bug? Or an error on my side?

Thanks!

Re: Submit gets done twice?

If the submit is done twice it's not likely it's a plupload issue since it never submits any form by default unless you use the HTML4 runtime.

Re: Submit gets done twice?

While Plupload does not do the submit itself, I was referring to the demo script, which does contain the code to submit, as I said, on line 54.

Since I had problems with the data which was sent, I went on debugging, and found that this "double submitting" was done because this (line 52-55):

uploader.bind('UploadProgress', function() {
    if (uploader.total.uploaded == uploader.files.length)
        $('form').submit();
});

Gets run twice. Like I said, I noticed since I replaced the submit with a simple alert(), and got 2 alert windows.
Since that happened, it made me think of a problem, which others might as well have.

Re: Submit gets done twice?

Could not reproduce it using the example on our site. Verified it with HTTP Fiddler on FF 3.6.3 and IE 8. dump.php is only executed once if I select a file and press the form submit button.

Re: Submit gets done twice?

I have the same problem.

Re: Submit gets done twice?

Do you guys block the event. That very important.

Re: Submit gets done twice?

Hi Spocke,

Yes, I block the event, as it's done in the Example script on line 61:

            e.preventDefault();

Again, I've used the exact code on the Examples page, which gives this problem.

Re: Submit gets done twice?

Well I can't really help you there unless it can be reproduced on our local examples.

Re: Submit gets done twice?

Hi guys,

Was any solution found for this problem? I have the same problem and can't seem to figure it out..

Re: Submit gets done twice?

If you block the event it should work. Works fine for me on all OS:es and browsers so I haven't been able to reproduce this.

Re: Submit gets done twice?

Spocke wrote:

If you block the event it should work.

Spocke, like i said here, at least in my case the event IS blocked. Again, as said, the example code is used.
So, this is not the solution.

What I've done is replace the code in the example in lines 52-55 with this:

uploader.bind('FileUploaded', function() {
    if (uploader.total.uploaded == uploader.files.length) {
        $('#upload_form').unbind("submit").submit();
    }
});

It's awkward, I know, but it works. Hope this helps for others as well. Tested in FF 3.6.3 to 3.6.6 on Ubuntu, 3.6.6 on Mac, Safari 4 on a Mac, IE 7 and 8 on Windows.

Re: Submit gets done twice?

Well if you need to unbind submit then there must be something custom bound to it. And Plupload doesn't use jQuery to bind events so it's not a plupload issue but probably some third party plugin for jQuery that adds to the forms.

So our example should work just fine if you just use the basic logic we have on the page.

Re: Submit gets done twice?

I got same problem but I solved.
When we use "UploadProgress" like this:

uploader.bind('UploadProgress', function() {

It means - that I understand - excute function() each file uploaded. So I changed "UploadProgress" to "FileUploaded". It works fine even though I miss understood about "FileUploaded". smile

I tested it on FF, Chrome, IE 6,7,8

Sorry about my english (I can't speak english well)

Re: Submit gets done twice?

Spocke wrote:

Well if you need to unbind submit then there must be something custom bound to it. And Plupload doesn't use jQuery to bind events so it's not a plupload issue but probably some third party plugin for jQuery that adds to the forms.

So our example should work just fine if you just use the basic logic we have on the page.

I logged in again, to see if anyone had the same problems I experienced earlier. Then I saw your reply.
Please, Spocke, read my posts.
Like I said, The submit action has been replaced by something else, namely an alert(). And a console.log(), to FireBug. This ALSO gets run twice; see my opening post.
Furthermore, you state I shouldn't experience this behaviour when I use the example code. Again, like I said in post 1, 3, 7 and 11 of this thread, I do. And I experience the problem.

My problem has been solved, like I stated earlier, but please, some advice: read the posts you're responding to. Don't take it personal, but repeating myself in every post seems a little odd... Also, like other people said, this problem recurs in their situations as well.
Seriously, I do like Plupload. It works like a charm -now-, and we and our customers really like it. But, these problems would make it useless. I submit a problem (like others), and the solution, and get the feeling it isn't taken seriously.

Last edited by tricksel (2010-11-11 13:01:52)

Re: Submit gets done twice?

If we can't reproduce it we can't solve it or help you solve it. It's as simple as that as stated a few times in this thread. Provide me with a link or tell me how to reproduce the double submit issue on the examples on this site then I have something to work with. I don't have time chasing ghost bugs that might be implementation specific I hope you understand.