PDA

View Full Version : AJAX return panel for display



catapult
6 May 2010, 12:32 AM
Hi all,

I'm after a little bit of advice and guidance. I have been using Extjs for a little while now and have used the AJAX functionality to submit values and handle returned data. I would like to know if it is possible to make an AJAX/server call to return a new Ext panel for display in another panel.

A good example would be a shopping cart system where a user would click on a product and the product's details would be displayed. As there are a multitude of different products all with different properties a fixed screen would not be adequate. So, I'm thinking I could send the product values to the server side script which would build the required screen and return it for display replacing the product list view.

I hope this makes sense. If anyone knows of any good tutorials or how I can do this I would be extremely grateful.

Cheers

evant
6 May 2010, 1:36 AM
var ct = new Ext.Panel({
width: 400,
height: 400,
renderTo: document.body,
tbar: [{
text: 'Load Panel',
handler: function(){
Ext.Ajax.request({
url: 'url',
success: function(response){
var o = Ext.decode(response.responseText);
// assumes the Ajax request returns:
// {title: 'Foo'}
ct.add(o);
ct.doLayout();
}
});
}
}]
});

catapult
6 May 2010, 4:34 AM
Thanks Evan that's great. I can now build a serverside screen builder to do what I need.