View Full Version : Display Message in Event Handler

13 May 2011, 9:22 AM
I'd like to display a message passed back from my server, someplace on my form. To start, I'd just like to 'alert' the message. I can see the json in Firebug's console/response - but msg is undefined.

Is my problem the json format, an incorrect reference to msg in the handler, or something else?

on the server:

if ($rs == 1)
echo '{"success": true, msg: "Thank you for your submission."}';
echo '{success: false}';


buttons: [{
text: 'Save',
handler: function(){
success: function(form, action, msg){

failure: function(form, action){...

13 May 2011, 9:53 AM
I don't see a url attribute in your form submit, but I'll assume that's a cut/paste error.

The success handler only accepts a form and action parameter, where you need to retrieve any messages from the action object. Note that the action object is implicitly decoded as JSON, so you can access its properties directly:

success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);

13 May 2011, 12:41 PM
That worked!

After looking at your answer, I again tried to see if I could find the answer in the docs myself and came to the submit method of Basicform, which if you click on the arrow, has a nice usage example. I've been missing these by clicking on the topic and going to the source code - which for me at this point - is a bit impenetrable.

Anyway, thanks so much friend.