Welcome Guest, Not a member yet? Register   Sign In
Passing GET value into function
#1

[eluser]alboyd[/eluser]
I feel like an idiot but please tell me what I am doing wrong? THis is soooo frustrating!

I need to use GET for a JQUERY autocompleter. I am sending URL

base_url/controller_name/function_name?q=Al

and
function function_name()
{
$get_val = $this->input->get('q');
echo $get_val;
die();
}

I get a blank page! What's up with that?? please help thanks
#2

[eluser]TheFuzzy0ne[/eluser]
Do you have query strings enabled? If so, I thought the syntax needed to be something like - http://your_site.tld/?c=controller_name&m=method&q=Al
#3

[eluser]alboyd[/eluser]
Thanks that improves the situation - however now I get a response Disallowed Key Characters from the autocompleter
#4

[eluser]Dam1an[/eluser]
There are a few threads on jQuery and autocomplete on the forums, maybe reading through them will give some pointers in the right direction

http://ellislab.com/forums/viewthread/113567/
http://ellislab.com/forums/viewthread/110744/
http://ellislab.com/forums/viewthread/103357/
http://ellislab.com/forums/viewthread/90604/

Hope these help
#5

[eluser]alboyd[/eluser]
That's awesome thanks heaps! Found the revised autocomplete code which users function params instead of GET. Much better thanks!! Now I just have to figure out why the auto-complete isn't inside my inputbox!
#6

[eluser]Evil Wizard[/eluser]
if you are using the JQuery autocomplete you just attach it to an id
Code:
$('#myinput').autocomplete('/url/to/autocomplete');
Thats the way I do it and the generated list appears below the input box.
#7

[eluser]coding_hero[/eluser]
If you are talking about this jQuery autocomplete:
http://www.devbridge.com/projects/autocomplete/jquery/

Then all you have to do is change the $.get() call to $.post() on line 222, and use $this->input->post('query') in CodeIgniter. If you're using a different jQuery library, then somewhere in there they likely make a $.get or $(this).get() call, and you can usually replace that with 'post' and be ok. The $.get() and $.post() functions both take the same parameters.




Theme © iAndrew 2016 - Forum software by © MyBB