PDA

View Full Version : Download file from server extjs with error message on fail



slamba
4 Mar 2015, 3:50 AM
I am using extjs-5 and want to download file from server. I implements code that working well for normal case but when server throws an error at that time my application redirect to another page to display that error.






Ext.create('Ext.form.Panel',{ standardSubmit:true,}).getForm().submit({ url: url, fileUpload:true,params:params, success:function(response, opts){if(successCallBack){ successCallBack.call(scope, response, opts);}}, failure:function(form, action){if(failureCallback){ failureCallback.call(scope, form, action);}}});


In normal case i am able to download file but when server throws any error that time i want to display that message instead redirect to another page.

yeghikyan
5 Mar 2015, 8:27 AM
It must work if you will remove "standardSubmit: true,"... i.e. ajax request.

slamba
8 Mar 2015, 8:37 PM
It must work if you will remove "standardSubmit: true,"... i.e. ajax request.

thank you for reply. but it will not download file. instead it will return file content to success method of ajax.

yeghikyan
9 Mar 2015, 1:04 AM
ach so... then put try-catch exception handling in your server side code and return normal header... :)

slamba
9 Mar 2015, 1:06 AM
if download fail then want to display proper error message. I can not understood what you want to say.