开发者

Fast redirect with background operations

开发者 https://www.devze.com 2023-02-02 02:48 出处:网络
For a click tracking feature I need to create a hidden page that reads a $_GET or $_POST tag, saves it to database, doe开发者_StackOverflows some data manipulation and redirects the user to another pa

For a click tracking feature I need to create a hidden page that reads a $_GET or $_POST tag, saves it to database, doe开发者_StackOverflows some data manipulation and redirects the user to another page. I want the redirect to be as fast as possible, and prefer to do the data manipulation after the redirect so that the user doesn't have to wait for it.

What is the best method to do so? The data manipulation actions are all background actions and have no user interface. I thought of initiating an AJAX call to a php page and redirecting the user without waiting for the AJAX response. The called php file will perform the operations in the background.

Will this work? Are there better alternatives?

I'm using php and jQuery (with CakePHP), but I guess this relates to all languages.

Many thanks in advance,

Dorian


Don't realy know how CakePHP handles things , but in Zend i have access to the part of the application that calls the controller/action based on the route , well i would fork/exec an external php file here witch would save the controller/action/route/whatever you need to save .

Edit

Aditionaly you can do it with ajax but you'll miss page-views and it seams harder to setup ( atleast in my opinion and i like to stay away from js as much as possible ) .

0

精彩评论

暂无评论...
验证码 换一张
取 消