I have a simulation of a loop where emails are sent out. Each email takes several seconds, so I'd like to have an indicator that shows a cumulative count as each has been sent. Some have told me that jQuery and AJAX cannot be used to do this. Has anyone had any experience in showing progress of a loop?
Again, the code below is a simulation.
Thank you...
Todd
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8" />
<title>Learn ajax</title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<?php
$rvars = $_REQUEST;
if (isset($rvars["count"])) $count = $rvars["count"];
else $count = 0;
if (isset($rvars["start"])) {
for ($i = 0; $i < 100; $i++) {
// Actually, each loop would be sending a email
$count = $i;
$rvars["count"] = $count;
}
}
?>
<h1> Test AJAX counter</h1>
<form id="countform" method="post">
<div>
<label for="start_button">Press to start sending emails: </br></label>
<input type="submit" value="Start" id="start_button" name="start" />
<input type="hidden" value=" <?php $rvars['count'] ?>
</div>
</form>
<div id="count_results">Count: <?php echo $count ?></div>
</body>
</html>