PDA

View Full Version : how to show loading icon at Ajax request for json



mxu
26 Dec 2007, 7:53 AM
hi,

i use Ext.Ajax.request for getting json from cgi call, and then
use
success: function ( result, request) {
var jData = Ext.util.JSON.decode(result.responseText);
...
var el = Ext.get(divID); //getCmp not working here
el.update(html, true);
to update the content of a panel.

but unfortunately the loading icon is not shown, how can I get loading icon show
during Ajax request call and el.update and then get rid of the icon after the request/
update are done ?

hendricd
26 Dec 2007, 8:16 AM
UpdateManager can handle to whole thing for you. But, since you are sending back JSON, you'll need to define a custom renderer to handle any conversion:


var myRenderer = function(el,response,um){

el.update(
Ext.decode(response.responseText).content? ;
,false);
};

var el = Ext.get(divID);
var um=el.getUpdateManager();
um.setRenderer({render:myRenderer });
el.load({
url: 'your.cgi'
,scripts:false
,target:el
,text: 'Loading...'

,failure:callHouston
,autoAbort:false
,disableCaching:true
});