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:
- <script type="text/javascript" language="javascript">
- // start spinner on button click
- $(document).ajaxSend(function(spinner) {
- $("#spinner").show();
- }
- );
- // refresh progress script and output to #content div
- function updateProgress(){
- $('#content').load('progress.php');
- }
- myTimer = setInterval( "updateProgress()", 2000 );
- // Execute the primary function
- $(document).ready(function() {
- $("#driver").click(function(event){
- $('#stage').load('execute.php');
- });
- });
-
- // hide spinner and content div when finished
- $(document).ajaxStop(function(spinner) {
- clearInterval(myTimer);
- $("#spinner").fadeOut("fast");
- $("#content").fadeOut("fast");
- });
- </script>