PDA

View Full Version : Form submit method failing to make post



x0ner
3 Jan 2011, 3:28 PM
For some reason when I try to submit using the form method I never see a post request. If I use the ajax method, it makes the post. Any ideas?



/**
* Create Case Form Panel
*/
SampleApp.CreateCase.FormPanel = function(){
SampleApp.CreateCase.FormPanel.superclass.constructor.call(this,{
id:'create_case',
labelWidth: 150,
frame:true,

url: 'controls/echo.php',
method:'POST',
waitTitle:'Connecting',
waitMsg:'Sending data...',
formBind: true,

title: 'New Case',
bodyStyle:'padding:5px 5px 0',
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: 'Event',
name: 'create_case_event',
allowBlank:false
})
],

buttons: [{
text: 'Save',
formBind: true,
handler:function(){
caseFormPanel = Ext.getCmp('create_case');
//Ext.Ajax.request({
caseFormPanel.getForm().submit({
success:function(){
Ext.Msg.alert('Status', 'Success!', function(btn, text){
if (btn == 'ok'){
var redirect = '#';
window.location = redirect;
}
});
},

failure:function(form, action){
if(action.failureType == 'server'){
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('Fail', obj.errors.reason);
}else{
Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ');
}
caseFormPanel.getForm().reset();
},
});
}
},{
text: 'Cancel'
}],

region: "south",
height: 300,
autoScroll:true
});
}

/**
* Create Case Form Panel
*/
Ext.extend(SampleApp.CreateCase.FormPanel, Ext.FormPanel, {
});

skirtle
3 Jan 2011, 3:55 PM
There are a couple of syntax errors in your code. There's an extra ) on the line just after allowBlank and there's an extra comma after your failure handler. Once I corrected those 2 errors it submitted the request fine for me.

Do you have Firebug installed? Are you using a JavaScript-ready IDE? Either one would have spotted these syntax errors.