Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery autocomplete not working for the first attempt
    text
    copied!<p>I have tried to implement dynamic autocomplete in my program. It is working perfectly after first input. But it doesn't show suggestions for the first attempt. However, server is responding the required source for autocomplete. Here is my code. </p> <pre><code> $('.autocomplete').live('keyup', function(){ $this = $(this); var search = $this.val(); $.ajax({ url:'/package/index/search/keyword/'+search+'/format/json', async: false, success: function(res){ //console.log(res.options); //console.log(res.defined_ids); staticObject = res.defined_ids; $this.autocomplete({ source: res.options }); } }); }); </code></pre> <p>Server side Code is</p> <pre><code> $keyword = $this-&gt;_getParam('keyword'); $elementDetailModel = new Package_Model_ElementDetail(); $arr = $elementDetailModel-&gt;searchElementDetail($keyword); $this-&gt;view-&gt;options = $arr['options']; // returns in the format array("test2","my new test", "night stay in delux room") $this-&gt;view-&gt;defined_ids = $arr['defined_ids']; // returns in the format array(21::21=&gt;"test2", 22::22=&gt;"my new test", 24::24=&gt;"night stay in delux room") </code></pre> <p>when I console logged defined_ids and options in firebug, I got following response when I typed 't' in the text field.<br> options: </p> <blockquote> <p>["test2", "my new test", "night stay in delux room"]</p> </blockquote> <p>defined_ids: </p> <blockquote> <p>Object { 21::21="test2", 22::22="my new test", 24::24="night stay in delux room"}</p> </blockquote> <p>Any help would be appreciable. Thanks in advance.</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