PDA

View Full Version : [SOLVED] Show Ajax request result in a panel



b3f3
12 Nov 2010, 2:14 PM
There is my code :


var orderPreviewContentResult ;

Ext.Ajax.request({
url : 'public/php/orderPreviewGrid.php',
method: 'GET',
success : function(response){
orderPreviewContentResult = Ext.decode(response.responseText);
}
});

var orderPreviewContent = new Ext.Panel({
layout: 'border',
items: [{
title: 'content',
region: 'center',
html: orderPreviewContentResult
}]
})orderPreviewContentResult is well html code.
... but the result of the request not shows in the panel.

Is someone know why ?

b3f3
12 Nov 2010, 2:30 PM
I try this but it don't works :

function toto() {
Ext.Ajax.request({
url : 'public/php/orderPreviewGrid.php',
method: 'GET',
success : function(response){
orderPreviewContentResult = Ext.decode(response.responseText);
return(orderPreviewContentResult);
}
})
};

alert(toto());->undefined

b3f3
12 Nov 2010, 7:26 PM
Here is the soluce :

Ext.onReady(function(){

Ext.Ajax.request({
url : 'public/php/orderPreviewGrid.php',
method: 'GET',
success : function(response){
var orderPreviewContentResult = Ext.decode(response.responseText);
Ext.getCmp('orderPreviewContentId').body.update(orderPreviewContentResult);
orderPreviewPanel.doLayout();
}
});

var orderPreviewContent = new Ext.Panel({
id: 'orderPreviewContentId',
layout: 'border',
items: [{
title: 'content',
region: 'center',
html: '<p>empty</p>'
}]
});

orderPreviewPanel = new Ext.Panel({
region: 'center',
margins: '10 10 10 10',
layout: 'border',
items: [{
region: 'north',
layout: 'fit',
border: false,
html: '<p>north content</p>'
}, {
region: 'center',
layout: 'fit',
items: [
orderPreviewContent
]
}]
});
});