Welcome Guest, Not a member yet? Register   Sign In
Submit to function without refresh or leaving page
#1

[eluser]Unknown[/eluser]
Hi,

I was wondering what the best way to do this would be. I have got a function that takes about an hour to run and so would not want the user sitting on the window for an hour. I am using:

Code:
ignore_user_abort(true);
   set_time_limit(6000);

To make sure the script runs without the user, however ideally I am wanting to run the function away from the browser, so on the forms post I can display a screen to say "We will email your results" without the page stuck on loading using something like flush.

The form submit happens inside my controller:

Code:
$this->form_validation->set_rules('keyword', 'Keyword', 'required');
  if ($this->form_validation->run() == true) {
   ignore_user_abort(true);
   set_time_limit(6000);
   $keyword = $this->input->post('keyword'); //get the keyword
   scrape_google_result_source($keyword);
   etc etc

Now this all works fine, but again it will refresh the page and leave it loading a good hour, what would be the best way to load a clean page instantly while the form is still being submitted?

Thanks,
Simon
#2

[eluser]CroNiX[/eluser]
Make an asynchronous request.
http://blog.markturansky.com/archives/205




Theme © iAndrew 2016 - Forum software by © MyBB