Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You want to change your configuration to setup the auto complete correctly:</p> <pre><code>$("#update-text").autocomplete("&lt;?php echo site_url('userProfile/autocomplete');?&gt;", {dataType:"json", type:'POST'}); </code></pre> <p>EDIT: also, there isn't a <strong>type</strong> option on the current autocomplete plugin, not that I'm aware of, which causes issues with CI's url get filtering (as seen in the code at <a href="https://github.com/agarzola/jQueryAutocompletePlugin/blob/master/jquery.autocomplete.js" rel="nofollow">https://github.com/agarzola/jQueryAutocompletePlugin/blob/master/jquery.autocomplete.js</a>). You might need to modify the autocomplete code to let you use POST.</p> <p>EDIT: you appear to be using the jQuery UI implementation, not the standalone. Looking at the options described at <a href="http://jqueryui.com/demos/autocomplete/" rel="nofollow">http://jqueryui.com/demos/autocomplete/</a> you can not pass in <em>dataType</em> and <em>type</em> options at the top level: those are unsupported. Also, you should change your codeigniter method to look like this (define <em>mycallback</em> before you use it):</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'); function mycallback ($var) { global $req; if (preg_match('/^'.$req.'/', $var)) { return $var; } } $array = array_filter($arrResults, 'mycallback'); // filter the array containing search word using call back function $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>EDIT 2: to use POST for your requests, try this:</p> <pre><code>$("#update-text").autocomplete({ source: function( request, response ) { $.post( "&lt;?php echo site_url('userProfile/autocomplete');?", { updateText: split(request.term).pop(); }, response ); }}); </code></pre> <p>Also, if you're using Firefox you can use Firebug to make sure requests are being fired.</p>
 

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