Welcome Guest, Not a member yet? Register   Sign In
progress bar with ajax : problem with ci3 resolved :)
#1

(This post was last modified: 05-30-2015, 10:57 AM by casa.)

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

Reply


Messages In This Thread
progress bar with ajax : problem with ci3 resolved :) - by casa - 05-28-2015, 10:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB