How to define CSRF token in ajax call in Cakephp 3. Also How CSRF can be off for some ajax requests
In Cakephp3 when the Csrf component is enabled. How I can use it in ajax call. In this beforeSend parameter of ajax csrf token is set in header. What is the value of csrfToken . As it gives error csrfToken is not defined beforeSend: function(xhr){ xhr.setRequestHeader('X-CSRF-Token', csrfToken); }, Also how can I disable Csrf component for some ajax calls. The CSRF component writes the current token to the request parameters as _csrfToken , you can get it via the request objects param() method (or getParam() as of CakePHP 3.4): setRequestHeader('X-CSRF-Token', <?= json_encode($this->request-