PDA

View Full Version : Responding to Element.load



adsen
16 Nov 2010, 9:12 PM
Suppose I have a form and the following code:

var submitMsg = Ext.get('divSubmitMsgId');
submitMsg.load({
url: 'submit.php',
params: <form params>,
text: 'submitting...'
});
submitMsg.show();

I want to then take action on this same page based on what submit.php returns. I cannot seem to figure out the "on success" or "on load" logic for the above load... how can I interpret the result of submit.php (not just display it)? If I simply try to get the dom.innerHTML, it returns the 'submitting...' text...

Screamy
17 Nov 2010, 10:25 AM
There's isn't a success/failure event for a Panel.load() (you'd have to use Ext.Ajax.request() for that), but there is a callback function you can use to get what you're after:


submitMsg.load({
url: 'submit.php',
params: <form params>,
text: 'submitting...',
callback: function(el, success, response, options) {
alert(response.responseText);
// you might also check response.status == 200
// to indicate success...
},
});

A Panel uses an Ext.Updater internally to perform a load(). The callback function parameters are documented in detail under Ext.Updater.update().

Thx