0

我需要使用 extjs4 将 php 变量的值传递给另一个文件,我在页面顶部有这个:

$userid = $_POST['userid'];

这是我的 extjs 代码

echo("
{
    title: 'Users',
    xtype: 'gridpanel',
    autoScroll: true,
    layout: 'fit',
    store: {
        storeId: 'test',
        fields: [
            {name: 'ID', type: 'string'},
            {name: 'Name', type: 'string'},
            {name: 'Admin', type: 'string'}
        ],
        proxy: {
            type: 'ajax',
            url : 'GetScripts/getUsers.php',
            reader: 'json'
        },
        autoLoad: true
    },

我需要将 $userid 传递给 getUsers.php。我可以得到一些帮助吗?

4

1 回答 1

2

在您的代理中,您可以像这样指定 URL 参数:

echo("
{
    title: 'Users',
    xtype: 'gridpanel',
    autoScroll: true,
    layout: 'fit',
    store: {
        storeId: 'test',
        fields: [
            {name: 'ID', type: 'string'},
            {name: 'Name', type: 'string'},
            {name: 'Admin', type: 'string'}
        ],
        proxy: {
            type: 'ajax',
            url : 'GetScripts/getUsers.php',
            reader: 'json',
            extraParams: { 
               userid: " . $userid . "
            }
        },
        autoLoad: true
    },

此外,当您加载商店时,您也可以传递参数

store.load({
    params : {
       userid : whateverUserId
    }
});
于 2012-06-08T16:39:12.643 回答