0

我已经成功完成了这个很棒的教程:http ://www.sencha.com/learn/ext-js-grids-with-php-and-sql/

我只是不能使用代理指定的 baseParams 字段......这是我遵循教程描述的代码:

__我的商店:Communes.js_ _ _

Ext.define('app.store.Communes', {
    extend: 'Ext.data.Store',
    id: 'communesstore',
    requires: ['app.model.Commune'],

config: {
    model: 'app.model.Commune',
    departement:'var',

    // the proxy with POST method
    proxy: new Ext.data.HttpProxy({
        url: 'app/php/communes.php',      // File to connect to
        method: 'POST'
    }),

    // the parameter passed to the proxy
    baseParams:{
        departement: "VAR"
    },

    // the JSON parser
    reader: new Ext.data.JsonReader({   
        // we tell the datastore where to get his data from
        rootProperty: 'results'
    },
    [
        {
            name: 'IdCommune',     
            type: 'integer'
        },

        {
            name: 'NomCommune',    
            type: 'string'
        }
    ]),
    autoLoad: true,
    sortInfo:{
        field: 'IdCommune', direction: "ASC"
    }
}

});

__ _ __ php 文件:communes.php _ ____

<?php

/**
 *  CREATE THE CONNECTION
 */
mysql_connect("localhost", "root", "pwd") or
        die("Could not connect: " . mysql_error());
mysql_select_db("databasename");

/**
 * INITIATE THE POST 
 */
$departement = 'null';
  if ( isset($_POST['departement'])){
    $departement = $_POST['departement'];   // Get this from Ext
  }

  getListCommunes($departement);

/**
 * 
 */
function getListCommunes($departement) {

[CODE HERE WORK FINE : just a connection and query but $departement is NULL]

}

?>

没有作为 POST 方法传递的参数...知道吗?

4

1 回答 1

1

那是因为 baseParams 是查询字符串的一部分,它们不是在 POST 正文中传递,而是在 url 中传递。

我不知道 PHP,但可能这有效:

if ( isset($_GET['departement'])){
    $departement = $_GET['departement'];   // Get this from Ext
}
于 2012-12-17T17:00:43.227 回答