I need to process a very long running process in PHP (grepping big text files and returning matching lines). When we run an average query from the command line, the process may take 10-15m.

I wanted to implement in PHP/jQuery, whereby I started the query, then showed incremental results as they came back.

I implemented something close, where I had one ajax call doing the search (worked fine), and had a periodic timer function running calling a second method in the class to get the results. However, I realized that the 2nd call would really create a new class instance, so the $this->current was different between the main query and the period update timer.

Here's the javascript I was trying (I was kicking it off when clicking a form button):

```
<script>
  function update_status(data) {
    alert(data);
    jQuery.each(data, function(key, val) {
      if ( key == "progress" )
        $("#progressbar").progressbar({ value: val });
    });
  }
  function progress_setup() {
    setInterval(function() {
      jQuery.ajax({
        type:'POST',
        dataType:'json',
        complete:function(XMLHttpRequest, textStatus){
          update_status(textStatus)
        },
        url:'<?php echo url_for("@grep_status"); ?>'
      })},
      2000);
  }
  function grep(elements) {
    jQuery.ajax({
      type:'POST',
      dataType:'html',
      data:jQuery(elements).serialize(),
      success:function(data, textStatus){jQuery('#results').html(data);},
      beforeSend:function(XMLHttpRequest){progress_setup()},
      url:'/grep'});
  }

</script>

```

But, this doesn't appear to be the right track. The core issue seems to be:

1. Long running task in PHP
2. How do you get the status of that task back to a progress bar, and an incremental results dialog?

TIA
Mike