# Autocomplete with ajax

**URL:** <https://discourse.cakephp.org/t/autocomplete-with-ajax/5950>\
**Category:** Need Help\
**Created:** [April 17, 2019, 10:16am UTC](https://discourse.cakephp.org/t/autocomplete-with-ajax/5950 "2019-04-17T10:16:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dolando](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@Dolando](https://discourse.cakephp.org/u/Dolando)\
**Post date:** [April 17, 2019, 10:16am UTC](https://discourse.cakephp.org/t/autocomplete-with-ajax/5950/1 "2019-04-17T10:16:54Z")

</div>

Hello

I would like to create a search-form so that after 2 or 3 typed characters the application starts making suggestions.  
Should I use “jQuery UI Autocomplete” ([[https://jqueryui.com/autocomplete/](https://jqueryui.com/autocomplete/)])  
or rather “AJAX for CakePHP” ([[https://github.com/dereuromark/cakephp-ajax](https://github.com/dereuromark/cakephp-ajax)])?  
Or is there another possibility?  
Please tell me what to prefer and why.

Thank you for your help.

I work with CakePHP 3.7.

---

<div class="post-metadata">

**Author:** ![spadeX](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@spadeX](https://discourse.cakephp.org/u/spadeX)\
**Post date:** [April 17, 2019, 10:50am UTC](https://discourse.cakephp.org/t/autocomplete-with-ajax/5950/2 "2019-04-17T10:50:42Z")

</div>

well, I have implement in jQuery ajax in search as key change in search box. If you want any plugin you can use it. ready-made plugin are also useful less implementation just install used it.

---

<div class="post-metadata">

**Author:** ![Diego](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/diego/32/296_2.png) [@Diego](https://discourse.cakephp.org/u/Diego)\
**Post date:** [April 17, 2019, 1:41pm UTC](https://discourse.cakephp.org/t/autocomplete-with-ajax/5950/3 "2019-04-17T13:41:13Z")

</div>

Select2:  
[https://select2.org/data-sources/ajax](https://select2.org/data-sources/ajax)

First create a function in the controller that search and return the results as json, request this function in the select2 ajax url

---

<div class="post-metadata">

**Author:** ![Dolando](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@Dolando](https://discourse.cakephp.org/u/Dolando)\
**Post date:** [April 18, 2019, 7:34am UTC](https://discourse.cakephp.org/t/autocomplete-with-ajax/5950/4 "2019-04-18T07:34:33Z")

</div>

Thank you very much for giving help.  
It looks like “AJAX for CakePHP” ist not the preferred solution.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [April 18, 2019, 12:30pm UTC](https://discourse.cakephp.org/t/autocomplete-with-ajax/5950/5 "2019-04-18T12:30:38Z")

</div>

“Ajax for CakePHP” does not directly provide autocomplete. It’s very useful, for what it does, but that’s not part of it.
