CodeIgniter Forums
Jquery CodeIgniter 2.X - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Jquery CodeIgniter 2.X (/showthread.php?tid=64146)



Jquery CodeIgniter 2.X - hubert10 - 01-20-2016

Hello,

I have a mistake in my dev that i don' t understand.
I have a form which is link to a controler projet/formulaire

In this form i have an input text with an ID="ref".

I want to use

$('#ref").autocomplete({
source: "<?php site_url('projet/autocomplete') ?>
})

But when I type one cheracter in my input text nothing happen.
In public function projet/autocomplete i put a javascript alert and it doesn't appear.
I think that it don't go to the projet/autocomplete

Somebody have an idea.
Have a nice
Best


RE: Jquery CodeIgniter 2.X - PaulD - 01-22-2016

Autocomplete is an ajax request so your contoller needs to echo results. Also you are using it wrongly as you need to define the serviceUrl: which returns the option data or provide the option data manually.

Have a look here:
https://www.devbridge.com/sourcery/components/jquery-autocomplete/

Or the API docs
http://jqueryui.com/autocomplete/

Hope that helps,

Paul.