Success handler not getting called in file upload using extjs -
i have j2ee web app form upload file location on server. during upload waitmsg shown user should disappear once upload completed msgbox indicating same. code success case provided in js file. upload works fine, waitmsg continues after upload @ server has completed.
js code given:
ext.onready(function(){ ext.quicktips.init(); var msg = function(title, msg){ ext.msg.show({ title: title, msg: msg, minwidth: 200, modal: true, icon: ext.msg.info, buttons: ext.msg.ok }); }; var fp = new ext.formpanel({ renderto: 'fi-form', fileupload: true, width: 500, frame: true, title: 'upload xml config file ', autoheight: true, bodystyle: 'padding: 10px 10px 0 10px;', labelwidth: 50, defaults: { anchor: '95%', allowblank: false, msgtarget: 'side' }, items: [{ xtype: 'fileuploadfield', id: 'form-file', emptytext: 'select xml file upload', fieldlabel: 'file', name: 'file', buttoncfg: { text: '', iconcls: 'upload-icon' } }], buttons: [{ text: 'upload', handler: function(){ if(fp.getform().isvalid()){ fp.getform().submit({ url: 'uploadxml.htm', waitmsg: 'uploading xml file...', success: function(fp, o){ msg('success', 'processed file "'+o.result.file+'" on server'); } }); } if (!validatefileextension(ext.getdom('form-file').value)) { ext.messagebox.alert('select file', 'only xml file, please.'); return; } } },{ text: 'reset', handler: function(){ fp.getform().reset(); } }] }); function validatefileextension(filename) { var exp = /^.*\.(xml|xml)$/; return exp.test(filename); } });
not sure missing.
in advance.
'uploadxml.htm' must php or similar server side procedure. php must return json string, : {'success':true} or {'success':false}.
Comments
Post a Comment