Hybrid View

  1. #1
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    11
    Vote Rating
    0
    hartste90 is on a distinguished road

      0  

    Question Store.Proxy.api Parameter POST

    Store.Proxy.api Parameter POST


    I am implementing a Proxy.api function in my store but cannot seem to access the parameters once they are passed to the .php files. The store is connected to a form.Panel and when I click "Create" on the form I want the form elements to be sent to a .php file to be stored in a MYSQL database.

    Here is the proxy with api configuration:
    Code:
    var store = Ext.create('Ext.data.Store', {
            //connect it to the person model
            model: 'User',
            autoLoad: true,
            autoSync: true,
            //set up the proxy to communicate the data
            proxy: {
                type: 'ajax',
                api: {
                    read: 'u_read.php',
                    create: 'u_create.php',
                    update: 'u_update.php',
                    destroy: 'u_update.php'
                },
                //create a reader to read from the database to the store
                reader: {
                    type: 'json',
                    successProperty: 'success',
                    root: 'data',
                    messageProperty: 'message'
                }
    I can see in FireBug that the 'create' command is executed correctly when I click the "CREATE" button in my application, and it correctly POSTs the 'data' json object:
    Capture.PNG


    but in the .php file I cannot access the 'data' json object or its contents.
    This is what I have in u_create.php:
    Code:
    <?php
            //get passed parameters
            $data = $_POST[data];
            
            $email = $data['email'];
            $first = $data['first'];
            $last = $data['last'];
            
            $response = array();
            $response['success'] = true;
            $response['message'] = "Created User";
            $response['data'] = array(
                'first' => $first, 
                'last' => $last,
                'email' => $email);
            return json_encode($response);
    ?>
    but the application doesn't return the $response json packet - it returns '0' and a 'result is undefined' error


    How can I access the POSTed arguments sent to my .php file from the proxy.api?

    Thanks in advance!

  2. #2
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default Data hold an another array

    Data hold an another array


    Hey,

    I think ur problem is in your data that you post, because it hold an another array and you try to find parameter like "$_
    POST[data['email']]".
    It should be $_POST[data[0]['email']] ... So you can find ur problem with "echo $data;" also..
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  3. #3
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    11
    Vote Rating
    0
    hartste90 is on a distinguished road

      0  

    Default


    bump!

    $_POST[data[0]['email']] produced a syntax error and wouldn't run


    I was able to find a workaround that works but I'm not sure how secure it is...
    Code:
    $data = json_decode(file_get_contents('php://input'))->data;
    $email - $data->email;
    //other values
    This works in my current situation but I really felt like there would be a more straightforward way to get the POST data - anyone have any clues??

    Thanks!

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,927
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      1  

    Default


    I use this as well.. should be fine. You can add projection (injection) to your data as needed.

    Scott.

  5. #5
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    11
    Vote Rating
    0
    hartste90 is on a distinguished road

      0  

    Default


    Okay I will continue using this. Thanks for the help - it would be nice to show more in depth examples of this feature. It was extremely helpful for me and any application with dynamic data!

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi