Newbie to AJAX: creating a counter
To get my feet wet, I have a simple page where I start a loop and I want to display the count:
- <body>
- <?php
- $rvars = $_REQUEST;
- if (isset($rvars["start"])) {
- for ($i = 0; $i < 10; $i++) {
- // The count variable
- $count = $i;
- sleep(1);
- }
- echo "Finished";
- }
- ?>
- <h1> Test AJAX counter</h1>
- <form id="countform" method="post">
- <div>
- <label for="start_button">Press to start:</label>
- <input type="submit" value="Start" id="start_button" name="start" />
- </div>
- </form>
- // Show count here
- <div id="count_results"></div>
- </body>
About as far as I have gotten is below, but I may be off to an incorrect start. Any help to get me started would be appreciated.