Tuesday, July 15, 2008

AJAX - Printing Catalyst Error response in extjs

I'm creating an application using Ext JS still and have done some AJAX connections to my Catalyst framework (Perl). Sometimes the scripts fail and the response text includes CSS and other such wonderful HTML goodies which ruins my current browser page. However I'd like to carry on so I used a ExtJS window to display the results and it all works swimmingly

The code looks a little something like this (my page doesn't do code to well)


Ext.Ajax.request({
url: '/Contact/save',
method: 'POST',
waitMsg:'Saving Data...',
success: function (response, options) {
Ext.MessageBox.alert('Message', 'Saved OK' + response.responseText);
},

failure:function(response, options) {
//Ext.MessageBox.alert('Message', 'Save failed ' +response.responseText);

win = new Ext.Window({
title:'Save Failed - Back End Error Message',
plain: true,
height:400,
width:600,
autoScroll:true,
items: [{html:response.responseText}]
});
win.show(this);
},
jsonData: formJsonData
});


This post can also be found in the ExtJS forum

http://extjs.com/forum/showthread.php?p=196929#post196929

2 comments:

Dan said...

Thanks, I'll be waiting for the application!

Hispanic tv advertising

Dan said...

I'll wait, hehe.. :)