Continue execution after rendering

in cakephp can I continue to execute a function after a render call? I am using ajax, and it would be nice to be able to clear the server side after rendering the response to the page. Of course, I could make another ajax call, but I would rather not ..

Tnx for any ideas. Bjorsa

0
source share
3 answers

From CakePHP docs (focus):

The render () method is automatically called at the end of each requested controller action. This method executes all the presentation logic (using the data that you specified when using the set () method), places the view inside its layout and returns it to the end user .

But, if you look at the source for AppController::render , it returns the processed output back to the calling method. So, theoretically you can do something like:

 $this->autoRender = false; $outp = $this->render('myView'); // do cleanup stuff echo $outp; exit(); 

As long as your autoRender set to false, you should be good. I personally have not tried this, but it looks like it should work the way you want. Good luck

+1
source

You can enter the file that contains the batch jobs, and then use cronjob to run CakePHP shells (which are executable scripts that have access to the infrastructure). Therefore, when you process an Ajax request, write down the batch process, and then schedule crontask to be processed at the specified interval.

CakePHP Shell Book Page

If you have a decent host, such as Dreamhost, you can easily schedule cron jobs and find the steps for this in the host documentation.

0
source

Depending on what exactly you want to do, you are likely to find a better way to do this. Having said that, exactly what for Controller::afterFilter() callback for.

0
source

Source: https://habr.com/ru/post/916784/


All Articles