Question on a jquery function

Question on a jquery function

I'm trying to run a function that executes a spinner while a PHP script is loading and also refreshes a PHP file that counts the number of rows inserted to show the script's progress.

This is what I have so far:

  1.  <script type="text/javascript" language="javascript">
  2. // start spinner on button click
  3.    $(document).ajaxSend(function(spinner) {
  4. $("#spinner").show();
  5. }
  6. );

  7. // refresh progress script and output to #content div
  8. function updateProgress(){
  9.     $('#content').load('progress.php');
  10. }
  11. myTimer = setInterval( "updateProgress()", 2000 );

  12. // Execute the primary function
  13.    $(document).ready(function() {
  14.       $("#driver").click(function(event){
  15.           $('#stage').load('execute.php');
  16.       });
  17.    });
  18.  
  19. // hide spinner and content div when finished
  20. $(document).ajaxStop(function(spinner) {
  21. clearInterval(myTimer);
  22. $("#spinner").fadeOut("fast");
  23. $("#content").fadeOut("fast");
  24. });
  25.    </script>