Results 1 to 2 of 2

Thread: $_POST receives several times the same method

  1. #1
    Sencha User
    Join Date
    Jun 2008
    Posts
    18
    Vote Rating
    0
      0  

    Default $_POST receives several times the same method

    I use the extension: Ext.ux.grid.KeyNav

    When I press the key "down" (next page), rapidly and several times,

    the $_POST receives several times the same method and parameters.

    Ex.:
    [{"action":"Controleacesso_UserController","method":"getall","data":[{"start":10,"limit":10,"sort":"m001usr_login"
    ,"dir":"ASC"}],"type":"rpc","tid":4},{"action":"Controleacesso_UserController","method":"getall","data"
    :[{"start":10,"limit":10,"sort":"m001usr_login","dir":"ASC"}],"type":"rpc","tid":5},{"action":"Controleacesso_UserController"
    ,"method":"getall"
    ,"data":[{"start":10,"limit":10,"sort":"m001usr_login","dir":"ASC"}],"type":"rpc","tid"
    :6},{"action":"Controleacesso_UserController","method":"getall","data":[{"start":10,"limit":10,"sort"
    :"m001usr_login","dir":"ASC"}],"type":"rpc","tid":7},{"action":"Controleacesso_UserController","method"
    :"getall"
    ,"data":[{"start":10,"limit":10,"sort":"m001usr_login","dir":"ASC"}],"type":"rpc","tid":8}]

    The solution was:

    Code:
    protected function _getDirect(){
            $isForm = false;
            $isUpload = false;
            if(!isset($HTTP_RAW_POST_DATA)){
                $HTTP_RAW_POST_DATA = file_get_contents('php://input');
            }
            if(isset($HTTP_RAW_POST_DATA)){
                header('Content-Type: text/javascript');
                $data = json_decode($HTTP_RAW_POST_DATA);
            }else if(isset($_POST['extAction'])){ // form post
                $isForm = true;
                $isUpload = $_POST['extUpload'] == 'true';
                $data = new BogusAction();
                $data->action = $_POST['extAction'];
                $data->method = $_POST['extMethod'];
                $data->tid = $_POST['extTID'];
                $data->data = array($_POST, $_FILES);
            }else{
                die('Invalid request.');
            }
            $response = null;
            if(is_array($data)){
                $response = array();
                $m = array();
                foreach($data as $d){
                    if(!in_array($d->method, $m)){
                        $m[] = $d->method;
                        $response[] = $this->_doRpc($d);
                    }
                }
            }else{
                $response = $this->_doRpc($data);
            }
            if($isForm && $isUpload){
                $ret = '<html><body><textarea>';
                $ret .= json_encode($response);
                $ret .= '</textarea></body></html>';
            }else{
                $ret = json_encode($response);
            }
            die($ret);
        }

  2. #2
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,488
    Vote Rating
    147
      0  

    Default

    The down action which is being executed should be buffered so that repeated actions cancel out previous ones. You will need to modify the ux to get this type of behavior.
    Aaron Conran
    @aconran

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •