0

I have successfully completed this great tutorial : http://www.sencha.com/learn/ext-js-grids-with-php-and-sql/

I just can't use the baseParams field specified with the proxy... Here is my code that follows tutorial description :

__ My Store : 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"
    }
}

});

_____ The php file : 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]

}

?>

There is no parameter passed as POST method... Any idea?

1
  • show us the request please. Commented Dec 17, 2012 at 17:51

1 Answer 1

1

That´s because the baseParams are part of the querystring, they are not passed in the POST body but in the url instead.

I don´t know PHP but probably this works:

if ( isset($_GET['departement'])){
    $departement = $_GET['departement'];   // Get this from Ext
}
Sign up to request clarification or add additional context in comments.

2 Comments

That would be suprising, no? I specified the method to be 'POST' to my proxy. Anyway I've tried your solution with no result... :/
No, that wouldn´t be surprising at all because it is a param and like any param it is passed in the url. And things passed in the url are not in the request body. The verb doesn´t matter here, what really matter is where the info is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.