PDA

View Full Version : FormPanel success and failure



wilbrandt
30 Jun 2009, 5:41 AM
I'm trying to have different actions be taken regarding the json response from a server when a form is submitted. However, try as I might, I cannot get the failure scenario to occur.

My understanding is that the json needs to return with an item of "success" that is either "true" or "false". If true, the success path is taken, if false, the failure one.

As stated, even when I return {success:false}, the success path is taken. I've tried reading examples and other posts and nothing appears to answer my question so far.

I would appreciate any insight as to why this doesn't work. I've tried responses of {success:false}, {"success":"false"}, and {"success":false} to no avail.


<namespaced method> = function() {
var uploadForm = new Ext.form.FormPanel({
baseCls: 'x-plain',
labelWidth: 50,
defaultType: 'textfield',
items: [{
fieldLabel: 'File',
name: 'file',
inputType: 'file',
allowBlank: 'false',
anchor: '100%'
},{
fieldLabel: 'Name',
name: 'name',
allowBlank: 'false',
anchor: '100%'
}],
fileUpload: true,
url: 'DbWriteServlet',
baseParams: {write: 'upload_audio', projectId: ii.vader.project.id}
});
var upload = new Ext.Window({
title: 'Add Audio File',
width: 450,
bodyStyle:'padding:5px;',
items: [
uploadForm
],
buttons: [{
text: 'Save',
handler: function() {
uploadForm.getForm().submit({
success:function() {
mxUtils.alert('Upload Complete.');
upload.close();
},
failure:function() {
mxUtils.alert('Upload failed.');
upload.close();
}
});
upload.hide();
}
},{
text: 'Cancel',
handler: function() {
upload.close();
}
}],
plain: true,
modal: true
});
upload.show();

};

Animal
30 Jun 2009, 6:31 AM
Setting the Content-Type header to text/html as instructed in the docs?

wilbrandt
30 Jun 2009, 6:44 AM
I didn't notice that requirement since it's on the BasicForm API page and not the FormPanel one.

That worked, though.

Thank you.