# Cake4: Beginner question. How use the ajax function

**URL:** <https://discourse.cakephp.org/t/cake4-beginner-question-how-use-the-ajax-function/9217>\
**Category:** Need Help\
**Tags:** help\
**Created:** [April 7, 2021, 9:40pm UTC](https://discourse.cakephp.org/t/cake4-beginner-question-how-use-the-ajax-function/9217 "2021-04-07T21:40:15Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Jawfin](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@Jawfin](https://discourse.cakephp.org/u/Jawfin)\
**Post date:** [April 8, 2021, 6:20am UTC](https://discourse.cakephp.org/t/cake4-beginner-question-how-use-the-ajax-function/9217/3 "2021-04-08T06:20:24Z")

</div>

As Cake is a server-side PHP framework I understand why they stopped attempting to support client-side javascript stuff.

I put together my approach to AJAX which uses both CSRF & form tampering protection here:-

> [@Working CSRF AJAX in CakePHP 4 - looking for criticism!](https://discourse.cakephp.org/t/working-csrf-ajax-in-cakephp-4-looking-for-criticism/7714/5):
>
> This is a complete build of a running AJAX using CakePHP4 with CSRF and Form Tampering protection. It reverses a user entered string. Create the ajax project: - composer self-update && composer create-project --prefer-dist cakephp/app:4.\* ajax Edit config/app\_local.php ... 'username' =\> 'root', 'password' =\> 'secret', 'database' =\> 'cake\_ajax', ... Or whatever your database is. For this demonstration I am using this table: - DROP TABLE IF EXISTS `myajax`; CREATE TABLE `myajax` ( …

I can only assume its a correct working approach as no-one yet has told me different!

---

_[View the full topic](https://discourse.cakephp.org/t/cake4-beginner-question-how-use-the-ajax-function/9217)._
