CodeIgniter | direct Echo during working script
Is it possible to echo something while the script for example is still running in a loop?
my problem: I ask the server with Ajax and then the server is fetching mails and store开发者_开发百科 them in Database. This took around 15 sec. During that Time the Server should echo his progress so that the Javascript can update a loading bar. This is working with a php script without CodeIgniter well.
Is there a way to skip the output class and all that stuff to get a direct echo?
Thanks
I remember reading somewhere that the CI output class basically create a output buffer for you (ob_start), so you should be able to flush the output using php's ob_ functions (I think, try it).
Alternatively, if you can't go around the buffer issue, you could have your script save the progress status in a session variable and do an interval call to a separate ajax method that returns just the value of that variable.. just an idea. Probably more reliable
You can 'echo' during script execution in CodeIgniter.
Maybe this is what you are looking for? From the User Guide on Views
There is a third optional parameter lets you change the behavior of the function so that it returns data as a string rather than sending it to your browser. This can be useful if you want to process the data in some way. If you set the parameter to true (boolean) it will return data. The default behavior is false, which sends it to your browser. Remember to assign it to a variable if you want the data returned:
$string = $this->load->view('myfile', '', true);
精彩评论