CodeIgniter Forums

Full Version: progress bar with ajax : problem with ci3 resolved :)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I use one controller, one library and one javascript file in order to show in a progressbar the progression of a making file.
In my view, i'have a button and a dropdown list. I choose one item of this dropdown list and then push the button.
A jquery action on this button send to my server a request to my controller.
The controller launches a function of my library which making my excel file.
During construction of my file, I update the progress of my file in the database (example : 5, 10, 15 ..., 80, 100 %).
Every fives seconds, in my wiew, a javascript function launches a request to this same controller, calling an another method who read my progression in my database and return json_encode values (example: echo json_encode(array('value' => $my_progress)) ; ). The json values is written in my progressbar.

I observe via firebug the progress of my request who is launched every 5 seconds. I never get back from the server except when the file is completely built (100%) . With version 2 of codeigniter , I use the same code and it works : every five seconds, the request is launched and i had my return (5 or 10 or 50 or 80 % etc.) and i can show the progress of the file, but with ci3 not. Can anyone help me?

Example :
My controller
PHP Code:
// function call by ajax request to make file
public function launch_making_file()
{
 
     $this->load->library('my_library') ;
 
     $this->my_library->do_action();
}

// function call by an ajax request to return the progress of file
public function get_progress()
{
 
     $query $this->db->get_where(....);
 
     echo json_encode(array('valeur' => $query->row()->val)) ;  // i have the good return. i test with a cache file to put the return and it's ok
 
     $query->free_result();

My Library
PHP Code:
public function do_action()
{
 
     ...... // some instructions
 
     $this->ci->db->update(...) ;  // record of the progress
 
     ....  // some instructions

My guess is the ajax request creating the file is keeping the session lock until it finished and the ajax request for the progress bar is waiting for the session lock to be released. You need to call session_write_close(). Read this section in the user guide: http://www.codeigniter.com/userguide3/li...oncurrency
(05-30-2015, 10:26 AM)includebeer Wrote: [ -> ]My guess is the ajax request creating the file is keeping the session lock until it finished and the ajax request for the progress bar is waiting for the session lock to be released. You need to call session_write_close(). Read this section in the user guide: http://www.codeigniter.com/userguide3/li...oncurrency
hello, Thanks you very much, that solved my problem. Smile