0

I am trying to trigger an event before a controller the action is called and even before the _construc function for that class is called.

I tried using cakephp beforeFilter, initialize and _construct method, didn't work as expected and i tried javascript code to trigger an event before the page is refreshed or reloads, but not working as expected. Here is the code i tried.

$(window).on('beforeLoad unload',function(){
$.get('http://www.antlax.com/provider/terminate');
});

I am expecting to terminate a process before the page is reloaded, so that at any giving time, there will be only one process for that page for all clients connected to the server.

sticky bit
  • 36,626
  • 12
  • 31
  • 42
Peter
  • 1,124
  • 14
  • 17
  • What you've shown is JavaScript code, which would have to be executed on the browser. The controller and it's constructor and action execute on the server side. – Greg Schmidt May 28 '19 at 04:40
  • Possible duplicate of [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) – Greg Schmidt May 28 '19 at 04:41

0 Answers0