Welcome Guest, Not a member yet? Register   Sign In
How to catch variable from classic url in codeigniter
#1

[eluser]redraw[/eluser]
yesterday i have found autocomplete plugin from : http://browse.feedreader.com/c/Humorous_...g/40643578

view :
Code:
$("#baja").autocomplete("<?php echo base_url();?>index.php/personalia/edit_baja/", {
         formatItem: function(rowdata) {
             var info = rowdata[0].split(":");
             return info[1];
         },
         formatResult: function (rowdata) {
             var info = rowdata[0].split(":");
             return info[1];
         }
     }).result(function(event, data, formatted){
             if(!data) {
                 $("#baja_id").val(info[0]);
             } else {
                 var info = formatted.split(":");
                 $("#baja_id").val(info[0]);
             }
     });

from that ajax script on view generate url like this :
Code:
GET http://localhost/rsmp/index.php/personalia/edit_baja/?q=d&limit=10&timestamp=1372750581577

controller :
Code:
Public function edit_baja()
{
   $q = isset($_POST['q']) ? $_POST['q'] : '';
  $limit = isset($_POST['limit']) ? $_POST['limit'] : "10";
  $que = "SELECT aid_masterjaba, masterjaba "
     ."FROM tu_masterjaba "
     ."WHERE masterjaba LIKE '%".$q."%' and tu_masterjaba.aktif = '1' ORDER BY masterjaba ASC LIMIT 0,$limit";
    
  $result = $this->db->query($que)->result();
  $customers = array();
  foreach($result as $baja)
  {
   echo "{$baja->id_masterjaba}:{$baja->masterjaba}\n";
  }
  }

the problem is the codeigniter cannot catch the 'q' value. so $q in query value is null. how to fix it
thank you
#2

[eluser]alexwenzel[/eluser]
For GET variables use:

$this->post->get()

Look in the documentation for the input class section.
#3

[eluser]redraw[/eluser]
[quote author="alexwenzel" date="1372752424"]For GET variables use:

$this->post->get()

Look in the documentation for the input class section.
[/quote]

thanks for the quick reply. but i still cannot get the value of 'q' even i already change to:
Code:
$q = $this->input->get($q, true)

or

$q = $this->input->get_post($q, true)

#4

[eluser]alexwenzel[/eluser]
look at documentation ^^

http://ellislab.com/codeigniter/user-gui...input.html

Code:
$q = $this->input->get('q');

#5

[eluser]redraw[/eluser]
[quote author="alexwenzel" date="1372754796"]look at documentation ^^

http://ellislab.com/codeigniter/user-gui...input.html

Code:
$q = $this->input->get('q');

[/quote]

still cannot catch the value of 'q'. I already try like you tell :
Code:
$q = $this->input->get('q');
#6

[eluser]Pert[/eluser]
You have to allow GET from application/config.php file

Code:
$config['allow_get_array'] = true;

There's some description on how it works above it in the configuration file.
#7

[eluser]alexwenzel[/eluser]
[quote author="Pert" date="1372759081"]You have to allow GET from application/config.php file

Code:
$config['allow_get_array'] = true;

There's some description on how it works above it in the configuration file.[/quote]

You are so right. Isn't it allowed by default?
#8

[eluser]Pert[/eluser]
I haven't changed my settings for GET, and it was set to false - so it must be default setting.

This is probably because GET is just invitation to mess about with variables on URL.
#9

[eluser]redraw[/eluser]
[quote author="Pert" date="1372759081"]You have to allow GET from application/config.php file

Code:
$config['allow_get_array'] = true;

There's some description on how it works above it in the configuration file.[/quote]

i add your code to my config.php but still cannot get the value of 'q' :down:

its value of q still empty.

thanks
#10

[eluser]Pert[/eluser]
There's already section for it, change that section. If you put your variable in too early, it will be overwritten by existing FALSE setting.




Theme © iAndrew 2016 - Forum software by © MyBB