# AJAX-Concept of CakePHP 2 and 3

**URL:** <https://discourse.cakephp.org/t/ajax-concept-of-cakephp-2-and-3/2334>\
**Category:** Need Help\
**Created:** [March 31, 2017, 11:54pm UTC](https://discourse.cakephp.org/t/ajax-concept-of-cakephp-2-and-3/2334 "2017-03-31T23:54:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tkh](https://avatars.discourse-cdn.com/v4/letter/t/c57346/32.png) [@tkh](https://discourse.cakephp.org/u/tkh)\
**Post date:** [March 31, 2017, 11:54pm UTC](https://discourse.cakephp.org/t/ajax-concept-of-cakephp-2-and-3/2334/1 "2017-03-31T23:54:17Z")

</div>

Hello all,

I’m learning CakePHP 2.x for some time and don’t had much experience with AJAX in the past.  
But now I would like to use it and I hope that somebody can explain me the basic concept of how AJAX and CakePHP works.  
In my tests I used the jQuery .load() function to open a regular view via GET and place the responce to the prefixed DIV.  
`$("#target_id").load(url, function() {});`  
Then I placed a save-button outside the #target\_id and used .ajax() function to POST the serialized form data within #target\_id.  
Even if this is working so far, it has some drawbacks, e.g.  
…clicking arbitrary links inside #target\_id (pagination links for example) results in opening the involved view instead loading it via AJAX  
…flash messages are not working at all  
Not least because the jsHelper is deprecated I wonder how to handle AJAX without placing buttons outside the view?  
I think I fundamentally misunderstood the whole AJAX thing and hope that you can tell me something about its underlying concept.  
Many thanks in advance  
tkh

---

<div class="post-metadata">

**Author:** ![jimgwhit](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/jimgwhit/32/378_2.png) [@jimgwhit](https://discourse.cakephp.org/u/jimgwhit)\
**Post date:** [April 1, 2017, 8:34pm UTC](https://discourse.cakephp.org/t/ajax-concept-of-cakephp-2-and-3/2334/2 "2017-04-01T20:34:24Z")

</div>

Please search right here I and others recently covered some ajax

---

<div class="post-metadata">

**Author:** ![McScreech](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mcscreech/32/465_2.png) [@McScreech](https://discourse.cakephp.org/u/McScreech)\
**Post date:** [April 6, 2017, 2:59pm UTC](https://discourse.cakephp.org/t/ajax-concept-of-cakephp-2-and-3/2334/3 "2017-04-06T14:59:34Z")

</div>

here are some links that i’ve found useful:

- two of the definitive sources:  
[http://api.jquery.com/jquery.ajax/](http://api.jquery.com/jquery.ajax/)  
[https://www.w3schools.com/xml/ajax\_intro.asp](https://www.w3schools.com/xml/ajax_intro.asp)

- i’ve always found the tutorialspoint site to be quite informative:  
[https://www.tutorialspoint.com/ajax/index.htm](https://www.tutorialspoint.com/ajax/index.htm)  
[https://www.tutorialspoint.com/jquery/jquery-ajax.htm](https://www.tutorialspoint.com/jquery/jquery-ajax.htm)

- a couple bloggers who’ve presented it nicely:  
[http://blog.teamtreehouse.com/beginners-guide-to-ajax-development-with-php](http://blog.teamtreehouse.com/beginners-guide-to-ajax-development-with-php)  
[https://www.sitepoint.com/use-jquerys-ajax-function/](https://www.sitepoint.com/use-jquerys-ajax-function/)

happy researching, McS

---

<div class="post-metadata">

**Author:** ![shaan007](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/shaan007/32/2765_2.png) [@shaan007](https://discourse.cakephp.org/u/shaan007)\
**Post date:** [April 7, 2023, 7:31am UTC](https://discourse.cakephp.org/t/ajax-concept-of-cakephp-2-and-3/2334/4 "2023-04-07T07:31:07Z")

</div>

hi @jimgwhit you can try it here

[![](https://img.youtube.com/vi/c3gbbW9oyds/hqdefault.jpg "cakephp 4 | cakePHP ajax plugin | ajax in cakephp | cakephp ajax request #linux #kalilinux #cakephp") ](https://www.youtube.com/watch?v=c3gbbW9oyds)
