Welcome Guest, Not a member yet? Register   Sign In
Calling a controller method asynchronous
#1

[eluser]Unknown[/eluser]
Hi,
i have following problem: I need to call a function in one of my controllers asynchronous, so that this code is evaluated in background. I dont want to use a cronjob, so i tried to do it with curl or fopen, but all methods return a 404 page not found error. I dont know how to solve this problem. I also thought of using ajax, but don't know how to implement it. My code structure is at follows:

- When the submit-button is pressed, a database entry is created which contains a counter
- Now the script has to call the asynchronous method, which loops until it reaches the counter and processes data
- While the data is processed, the user should get back to the user interface to interact with the webpage; there is also a page where he can see the progress of the data performing; the return to the interface should be immediately, so that the method call don't blocks

But it doesn't work. Is there a simple solution?
#2

[eluser]Krzemo[/eluser]
Unfortunately PHP doesn't allow/support multithreading.
This might be a help to you: http://phplens.com/phpeverywhere/?q=node/view/254

Regs
#3

[eluser]Unknown[/eluser]
Hmm, i tried the method once before, but this one looks better. Unfortunately i get a HTTP 302 Page Found response, but nothing more. Crazy thing...

This is the result from the GET:

HTTP/1.1 302 Found Date: Sun, 15 Aug 2010 22:01:44 GMT Server: Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 X-Powered-By: PHP/5.3.1 Set-Cookie: ci_session=a:4:{s:10:"session_id";s:32:"fdcb977b9e1c1be9aa6b06bd0def9c68";s:10:"ip_address";s:7:"0.0.0.0";s:10:"user_agent";s:0:"";s:13:"last_activity";s:10:"1281909704";}e978ad0ea0ffdaf6f8a6d3a09b424962; expires=Mon, 16-Aug-2010 00:01:44 GMT; path=/ Location: http://localhost/mms/index.php/userController/noPriv Content-Length: 0 Connection: close Content-Type: text/html
#4

[eluser]WanWizard[/eluser]
Which means you get a HTTP redirect in return.




Theme © iAndrew 2016 - Forum software by © MyBB