views:

189

answers:

2

I have an existing panel where I set the html manually with a variable like so:

s = '<H1>My Html Page';
s += '[more html]]';

 var panel = new Ext.Panel({
            id: 'service_Billing',
            title: 'Billing',
            tbar: [],
            html: s
        });

How can I specify a path on same server server of a .php file instead of the variable as the source of the html. Something like /path/example/data.php

+2  A: 

Use Ext.Ajax to grab the content and update the panel:

var panel = new Ext.Panel(...);
Ext.Ajax.request({
  url: '/your/script.php',
  success: function(response,opts){
    opts.panel.update(response.responseText);
  },
  panel: panel
});

Or something like that ought to do it.

timdev
There is no `panel` config on Ajax.request -- do you mean `scope`? Panel's `autoLoad` config as shown by @wombleton is the best approach.
bmoeskau
scope would work too (and is probably better). I just wanted a reference to the panel inside the handler (here: opts.panel). This does work.
timdev
+5  A: 

You're looking for autoLoad.

var panel = new Ext.Panel({
  autoLoad: '/path/example/data.php',
  id: 'service_Billing',
  title: 'Billing',
  tbar: []
});
wombleton
+1 I had forgotten about that!
timdev