Sunday 15 January 2012

javascript - Jquery autocomplete not working from within a get ajax request -


I am using the jQuery AutoComplete plugin (). I have an input field that is in my page. The following code works.

  & lt; Script & gt; $ (Document) .ready (function () {somedata = "Core selector features: Traversing Manipulation CSS Events Exciting Electronic Effects Ajax Utilities" .split (""); $ ("#by"). Autocomplete (somedata); & lt; / Script>  

Now, when the focus is focused by the input field, I get an AJAX request that correctly obtains the data in which some strings " N ", and I want to Populate the fields with the collected data, but call it automatically within $ $. The job is not working, as shown below. Any way to fix this?

  $ (document) .ready (function) {Somedata = "Core selector features: Traversing Manipulation CSS Events Exciting Electronic Effects Ajax Utilities" .split ("") var url = "& lt; some URL here"; $ ( "#by"). Focus (function () {$. (URA , Function (result) {$ ( "#" by). Auto does not work integer (somedata); // $ ( "by" #). Autocomplete (result. Split ( "\ n")); // does not work}};});});  

Thank you.

Focus event too late to load values ​​for autocomplete plug- From the details of these:

By giving or entering something in an autocomplete field, the plugin starts searching for matching entries and displays a list of values ​​to select from Does. By entering more characters, the user can filter the list for better matching.

Focus event works automatically when you are triggered You are trying to load data from the same event. In fact you load the data after the event, since $ .get method The callback of is called asynchronous.


No comments:

Post a Comment