Ajax Jquery : GET or POST how to catch data in controller ? |
[eluser]ludo31[/eluser]
Hello ; I test my code with Ajax and I would like to know how to catch data in controller : if we have something like this in view and in script javascript Code: $.ajax({ and We would like to send it in controller : Code: data : 'q='+$(this).val() , how to catch q ??? in GET or POST because in simple php code we can make : Code: $_GET['q'] but in codeigniter I don't know if it works with input->post ??? I see also in doc the function Code: $this->input->is_ajax_request() I don't know !!! it is the same problem I know how to call function in controller using json type but I don't now how to pass a data and cath it in controller : Code: [removed] and in my controller Code: public function get_all_users(){ thanks
[eluser]Stefan Hueg[/eluser]
Hi, everything is described here: http://ellislab.com/codeigniter/user-gui...input.html Code: $q = $this->input->post('q'); //for post requests, q is the key Those function will sanitize the variables for you, so that you don't have to worry about XSS. Passing data via AJAX is done using the data-variable inside your $.ajax function, for ex.: Code: $.ajax({ Try to stick to this structure and you are fine. |
Welcome Guest, Not a member yet? Register Sign In |