Request Ajax Codeigniter

1

I'm getting the following error when sending when sending json data via ajax using the codeigniter: Disallowed Key Characters. When I send only one object it works without problems, but when I send more than one object it returns the error.

jQuery.post( "http://localhost/endereco", 
                    {informacao1:"dado1", informacao2:"dado2"},
                    function(data){     

                            alert(data);

                    }   
        );
    
asked by anonymous 19.08.2014 / 20:44

1 answer

1

What you can do is create a file MY_Input.php within application / core

<?php

class MY_Input extends CI_Input {

    /**
     * Clean Keys
     *
     * This is a helper function. To prevent malicious users
     * from trying to exploit keys we make sure that keys are
     * only named with alpha-numeric text and a few other items.
     * 
     * Extended to allow: 
     *      - '.' (dot), 
     *      - '[' (open bracket),
     *      - ']' (close bracket)
     * 
     * @access  private
     * @param   string
     * @return  string
     */
    function _clean_input_keys($str)
    {
        if ( ! preg_match("/^[a-z0-9:_\/\.\[\]-]+$/i", $str) )
        {
            exit('Disallowed Key Characters.');
        }

        // Clean UTF-8 if supported
        if (UTF8_ENABLED === TRUE)
        {
            $str = $this->uni->clean_string($str);
        }

        return $str;
    }

}
    
19.08.2014 / 20:48