PDA

View Full Version : Going to next page after submitting the form



preeti16
26 Oct 2012, 2:07 PM
Hello Friends,
I am new to Extjs and java script. I have a simple form with 3 text field. On submit I want to go on next page(result page). When I click on submit button I do see the response coming back in firebug but the result page does not get loaded. How do I load the next page? If it is ajax based submit, how do i make it non ajax .I searched the internet but could not find much resource on it. Any help will be appreciated.


Ext.require([
'Ext.form.*'
]);


Ext.onReady(function() {


var formPanel = Ext.create('Ext.form.Panel', {
frame: true,
title: 'New Todo',
width: 340,
bodyPadding: 5,
url: 'result.html',
ajaxSubmit:false,
fieldDefaults: {
labelAlign: 'left',
labelWidth: 90,
anchor: '100%'
},


items: [{
xtype: 'textfield',
name: 'id',
fieldLabel: 'id',
value: ''
},{
xtype: 'textfield',
name: 'Summary',
fieldLabel: 'Summary',
value: ''
}, {
xtype: 'textareafield',
name: 'Description',
fieldLabel: 'Description',
value: ''
}],

// Reset and Submit buttons
buttons: [{
text: 'Submit',
formBind: true, //only enabled once the form is valid
disabled: true,
handler: function() {
var form = this.up('form').getForm();
//var url = 'result.html';
if (form.isValid()) {
form.submit({
url: 'result.html',
//window.open(url);

});
}
}

}],


});

formPanel.render('form-todo');


});

mitchellsimoens
29 Oct 2012, 6:14 AM
Have you tried putting the success callback in the form.submit? Also, submitting to result.html?

preeti16
1 Nov 2012, 11:28 AM
Yeah, I tried the success call back. I can not even see alert 2 and 3. But the Post get submitted and I can see the response back in fire bug. What am I doing wrong?


buttons: [{
text: 'Submit',
formBind: true, //only enabled once the form is valid
disabled: true,
handler: function() {
var form = this.up('form').getForm();
alert("1");
form.submit({
//clientValidation: true,
url: 'result.html',
success: function(form, action) {
alert("2");
},
failure: function(form, action) {
alert("3");
}
});

}

}],

mitchellsimoens
1 Nov 2012, 12:25 PM
What is your response like?

preeti16
1 Nov 2012, 12:27 PM
Response is html of result.html. One more questions I have is. why i can not see the alert 2 or 3.

mitchellsimoens
2 Nov 2012, 4:39 AM
You need to return something like


{
"success" : true
}