views:

14

answers:

1

I'm using the Codeigniter framework and have tried to stick with the MVC philosophy as best I can. I've recently run into an issue that I'm not entirely sure how to handle.

I have a PHP script running that takes a fairly long time (creating an index for my search engine). What I want to do is have the html show up as it's running.

If I just put echo statements into my controller, and echo every time a document is indexed, it does what I want. I can watch the progress as it happens.

But that doesn't correspond with an MVC philosophy, and I also don't get any of the nice styles and html formatting that is set up for my view classes.

The only way I know to interact with my view is to run the code in the controller, and store the log info into a variable, then pass it to the view when I'm done. But that means I just sit waiting for ages, and finally a big log display shows up (nicely formatted, mind you).

Does anyone know how to do what it is I'm trying to achieve? Use a View, but before the Controller is "done" yet?

+2  A: 

You can load multiple view's in a controller, how about loading and displaying a view first and then doing more processing.

There is even the possibility of loading a page (like an outside frame or something) and then using JQuery to load the content that is taking a long time to load.

Kieran Andrews
Im not sure why you would want to create a page that takes so long to load, maybe consider caching some of the information, but I dont have enough knowledge of what you are building to be right about this.
Kieran Andrews
Well, I have a button in my site that if I click on it, it runs a bunch of data through Lucene to create an index that is used by the search features on the site. I was just hoping to sort of "watch" as it indexed away, rather than just look at a busy mouse until the success page eventually loads.
neomech
A dodgy way to do this is to make a new method in the controller (e.g. function lucene() ) and then have this method echo the data from the search log. You can then call this from ajax on the main page.
Kieran Andrews