Callbacks out of order, IE triggers onbeforeunload
Posted: Wed Jul 25, 2012 9:34 pm
I'm using JFileUpload for an asset management system and I want to use the onbeforeunload event to make sure everything is squared away as it should be if they exit the window as the uploader is working. The event cancels the upload and calls another script to handle the files already on the server.
I have it working in every browser except for IE (of course), which always triggers the onbeforeunload event at the very start of any and every upload. I've tracked down the culprit, so far as I can tell. In my event log, I'm getting certain callbacks out of order. Here's a couple examples.
In the case of the third example, the upload continued despite the upload being "cancelled" twice, so I had to manually cancel it.
The main pattern is that the Split callbacks are in the order "Triggered" -> "Completed" -> "Started" which makes no sense, and I think that's the source of the problem. Every so often JSTransferStarted will happen before JSSplitStarted is called back, as in the fourth example.
This only happens for the first file in any upload and only in IE. The file does make it to the server uncorrupted in any way, but this makes multi-file uploads impossible.
Now, there are two things I need to know.
1. Is there anything stemming from these mis-ordered callbacks that could trigger the onbeforeunload event? MSIE uses some pretty stupid triggers, like document.write, so it's believable that there's something triggering the event.
2. Is there any way to prevent this from happening?
Thank you.
I have it working in every browser except for IE (of course), which always triggers the onbeforeunload event at the very start of any and every upload. I've tracked down the culprit, so far as I can tell. In my event log, I'm getting certain callbacks out of order. Here's a couple examples.
Code: Select all
JSAppletInitialized(JFileUpload 2.7 Build FINAL.001)
JSTransferTriggered(CookieMonster.jpg|PossiblePageTabImage.png|PossiblePageTabImage2.png)
JSSplitTriggered(CookieMonster.jpg,66989,67108864,1)
JSSplitCompleted(1)
JSTransferStarted(CookieMonster.jpg,66989)
JSTransferCancelled()
JSSplitStarted(1,66989)
Code: Select all
JSAppletInitialized(JFileUpload 2.7 Build FINAL.001)
JSTransferTriggered(Beethovens Symphony No 9 - Copy.mp3|Beethovens Symphony No 9.mp3|Sad Ending Trio speed.mp3)
JSSplitTriggered(Beethovens Symphony No 9 - Copy.mp3,605654,67108864,1)
JSSplitCompleted(1)
JSTransferStarted(Beethovens Symphony No 9 - Copy.mp3,605654)
JSSplitStarted(1,605654)
JSTransferCancelled()
JSTransferCancelled()
Code: Select all
JSAppletInitialized(JFileUpload 2.7 Build FINAL.001)
JSTransferTriggered(gmw3059_groups.sql|some_users.sql)
JSSplitTriggered(gmw3059_groups.sql,3736495,67108864,1)
JSSplitCompleted(1)
JSSplitStarted(1,3736495)
JSTransferCancelled()
JSTransferCancelled()
JSTransferStarted(gmw3059_groups.sql,3736495)
JSTransferCompleted(gmw3059_groups.sql.1)
JSSplitTriggered(some_users.sql,9355781,67108864,1)
JSSplitStarted(1,9355781)
JSSplitCompleted(1)
JSTransferStarted(some_users.sql,9355781)
JSTransferCancelled()
Code: Select all
JSAppletInitialized(JFileUpload 2.7 Build FINAL.001)
JSTransferTriggered(oats_14.mov)
JSSplitTriggered(oats_14.mov,2077155,67108864,1)
JSSplitCompleted(1)
JSTransferStarted(oats_14.mov,2077155)
JSSplitStarted(1,2077155)
JSTransferCancelled()
JSTransferCancelled()
The main pattern is that the Split callbacks are in the order "Triggered" -> "Completed" -> "Started" which makes no sense, and I think that's the source of the problem. Every so often JSTransferStarted will happen before JSSplitStarted is called back, as in the fourth example.
This only happens for the first file in any upload and only in IE. The file does make it to the server uncorrupted in any way, but this makes multi-file uploads impossible.
Now, there are two things I need to know.
1. Is there anything stemming from these mis-ordered callbacks that could trigger the onbeforeunload event? MSIE uses some pretty stupid triggers, like document.write, so it's believable that there's something triggering the event.
2. Is there any way to prevent this from happening?
Thank you.