Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Jul 2005
    Location
    UK
    Posts
    1,051
    Thanks
    6
    Thanked 13 Times in 13 Posts

    PHP and AJAX autosuggest/autocomplete function?

    Does anyone know of a ready to run PHP and AJAX autosuggest/autocomplete function that they have used with success?

    I've found many promising leads via a Google search but they tend to be missing a crucial element such as being keyboard navigable, or only cover the AJAX side of things.

    I figure someone on here almost certainly has found one that does the job, however.

    Thanks in advance.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    jQuery has some nice plugins. This one looks good:

    http://www.kvaq.sk/medialib/stuff/jQuery/plugins/kvAC/

    Oh this one is nice too:

    http://loopj.com/2009/04/25/jquery-p...te-text-entry/
    http://loopj.com/tokeninput/demo.html

    You may like this one better though:

    http://www.devbridge.com/projects/au.../jquery/#howto

    Oh wow check this one out, it handles multiple selections in an interesting way:

    http://www.iantearle.com/projects/facelist

  • #3
    New Coder
    Join Date
    Nov 2008
    Posts
    59
    Thanks
    5
    Thanked 4 Times in 4 Posts
    Wow, I actually wrote my own for my own website, but it was very basic. When you had typed 3 characters it submitted a request to another url and got back some javascript which it then executed to fill in an array you could cycle through.

    I'm really thinking of changing it for the last one on your list now though as it looks and performs 100x better. Thanks!

  • #4
    Senior Coder
    Join Date
    Jul 2005
    Location
    UK
    Posts
    1,051
    Thanks
    6
    Thanked 13 Times in 13 Posts
    Thanks Fumigator. None of these actually give me any PHP code, but what I'm realising is that the PHP part of this is really simple and not worth providing code for.

    So, when I'm told something like this:

    Web page that provides data for Ajax Autocomplete, in our case autocomplete.ashx will receive GET request with querystring ?query=Li, and it must return JSON data in the following format:

    {
    query:'Li',
    suggestions:['Liberia','Libyan Arab Jamahiriya','Liechtenstein','Lithuania'],
    data:['LR','LY','LI','LT']
    }
    Does that mean, essentially, that autocomplete.ashx (or .php in my case) outputs literally the above in text format?

  • #5
    New Coder
    Join Date
    Nov 2008
    Posts
    59
    Thanks
    5
    Thanked 4 Times in 4 Posts
    I realise this thread is now 2 weeks old, but maybe the poster still wants an answer.

    Yes, the search results provided by your php or whatever script has to return valid JSON encoded data. PHP has support for this - just make sure that the json.so (.dll on Windows) extension is loaded.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •