PDA

View Full Version : How to handle connection reset in file upload?



pk55555
16 Apr 2013, 11:06 AM
Hi, I am trying to upload a file using Ext.form.Panel. On click on import button in import panel my code is like this:

if (form.isValid()) {
form.submit({
hasUpload: true,
waitMsg: 'some message',
success: function (file, action) {
//msg },
failure: function (file, action) {
//msg }
.........

This code is working fine and I am able to upload file successfully. But the problem which I am facing is during the time of upload, if I loose connection or bring down the server, I keep seeing progress bar with waitMsg. There is no way to stop it unless I refresh the page. I tried to use 'timeout' in the form but the form is not timing out in this case. Let me know what is the best way to handle such case.
Thanks.

slemmon
18 Apr 2013, 9:43 AM
Try setting a timeout that hides the MessageBox with x seconds (in the event your server simply doesn't respond).

From the example at:
http://docs.sencha.com/extjs/4.2.0/extjs-build/examples/message-box/msg-box.html



setTimeout(function(){
//This simulates a long-running operation like a database save or XHR call.
//In real code, this would be in a callback function.
Ext.MessageBox.hide();
Ext.example.msg('Done', 'Your fake data was saved!');
}, 8000);