Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery ui autocomplete not working with code igniter
    primarykey
    data
    text
    <p>What I want to do is simple. I want the user to be able to put in a name and while inserting code igniter and JQuery ui looks up the database and starts posting recommendations .. So this is what I got so far with a bit of help from someone here on stackoverflow .. But its still not working at all.</p> <p>The Jquery ui command</p> <pre><code>$("#update-text").autocomplete({source:"&lt;?php echo site_url('userProfile/autocomplete');?&gt;",dataType:"json", type:'POST'}); </code></pre> <p>The form containing the text field in the php file</p> <pre><code>&lt;div&gt; &lt;form method="post" action="#" name="updatePlanForm"&gt; &lt;div class="ui-widget"&gt; &lt;label for="update-text"&gt;&lt;/label&gt; &lt;input type="text" id="update-text" name="updateText" value="What are you gonna do today?" onclick="removeText()"/&gt; &lt;/div&gt; &lt;input type="button" class="small green button" value="Update Plan" name="updatePlanButton"/&gt; &lt;!-- once clicked JQuery sends a post to a controller send_plan and jquery will return the view --&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>And finally I have a controller called userProfile and in it is a function called autocomplete</p> <pre><code>function autocomplete(){ // this takes the text field and whatever the user writes it autocompletes it. //Every single place and event in the database should be displayed in this view in this format $req = $this-&gt;input-&gt;post('updateText'); $arrResults = array('orange', 'apple', 'bannana'); $array = array_filter($arrResults, 'mycallback'); // filter the array containing search word using call back function function mycallback ($var) { global $req; if (preg_match('/^'.$req.'/', $var)) { return $var; } } $array1 = array(); // filter null array foreach ($array as $arr =&gt; $val) { if(!empty($val)) { $array1[] = $val; } } //echo out the json encoded array echo json_encode($array1); } </code></pre> <p>The below code is added for @Andrew</p> <pre><code>&lt;!-- styles --&gt; &lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url().''?&gt;public/styles/general.css"/&gt; &lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url().''?&gt;public/styles/homepage.css"/&gt; &lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url().''?&gt;public/styles/css-buttons.css"/&gt; &lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url().''?&gt;public/styles/colors.css"/&gt; &lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url().''?&gt;public/plugin/jqui/css/south-street/jquery-ui-1.8.11.custom.css"/&gt; &lt;!-- scripts --&gt; &lt;script type="text/javascript" src="&lt;?php echo base_url().''?&gt;public/scripts/removeTextClick.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="&lt;?php echo base_url().''?&gt;public/scripts/jquery-1.4.4.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="&lt;?php echo base_url().''?&gt;public/plugin/jqui/js/jquery-ui-1.8.11.custom.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#abso").hide(); $("#close").hide(); $("#activity-feed").load("&lt;?php echo site_url('userProfile/update_plan_feed');?&gt;"); // if removed from userProfile then change here too $("#places-feed").load("&lt;?php echo site_url('userProfile/suggested_places_feed');?&gt;"); // if removed from userProfile then change here too $("#events-feed").load("&lt;?php echo site_url('userProfile/suggested_events_feed');?&gt;"); // if removed from userProfile then change here too $("#list-friends-feed-link").click(function(){ //start click $("#abso").load("&lt;?php echo site_url('userProfile/list_freinds');?&gt;"); $("#abso").slideDown("600", function(){}); $("#close").slideDown("600", function(){}); }); //end click $("#list-pictures-feed-link").click(function(){ //start click $("#abso").load("&lt;?php echo site_url('userProfile/pic_feed');?&gt;"); $("#abso").slideDown("600", function(){}); $("#close").slideDown("600", function(){}); }); //end click $("#list-groups-feed-link").click(function(){ //start click $("#abso").load("&lt;?php echo site_url('userProfile/list_groups');?&gt;"); $("#abso").slideDown("600", function(){}); $("#close").slideDown("600", function(){}); }); //end click $("#notify").click(function(){ //start click $("#abso").load("&lt;?php echo site_url('userProfile/list_notifications');?&gt;"); $("#abso").slideDown("600", function(){}); $("#close").slideDown("600", function(){}); }); //end click $("#close").click(function(){ //start click $("#abso").slideUp("600",function(){}); $("#close").slideUp("600",function(){}); }); //end click $("#broadcast-button").click(function(){ $.post("&lt;?php echo site_url('userProfile/send_broadcast'); ?&gt;", $("#broadcast-form").serialize()); }); $("#update-text").autocomplete({source:"&lt;?php echo site_url('userProfile/autocomplete');?&gt;",dataType:"json", type:'POST'}); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload