Reputation: 509
Ok i have this portion of code
<script type="text/javascript" src="ajaxsbmt.js"></script>
<?php
for ($i=0; $i <=20; $i++) {
if ($i == 0) {
$valor = "";
$desde= "";
$inicio = "0";
}
else {
$valor = ($i*50)+1;
$desde = "_Desde_";
}
$analisar = $_POST['string']."".$desde."".$valor;
// echo $valor;
?>
<div style="float:left;">
<form id="formproduto<?php echo $valor; ?>" name="form<?php echo $valor; ?>" action="#produto" method="post" onsubmit="xmlhttpPost('analisar.php', 'formproduto<?php echo $valor; ?>', 'produto', '<img src=\'ajax-loader.gif\'>'); return false;"><input type="hidden" value="<?=$analisar?>" name="analisar" />
<input type="submit" value="<?php if ($i == 0) { echo $inicio; } else { echo $valor; } ?>" />
</form>
</div>
<?php } ?>
<div id="produto"></div>
What i need is to submit the loop (using my already existant ajaxsbmt.js routine (that get the form value and show into the div "produto"
BUT i would like this script runs automatically, like after 5 seconds delay each other for example
So its gona be like this, When i press submit (or "0" button for example) the javascript (or another thing) submit that form wait for the results and then wait N seconds until the next step of the loop.
Any suggestions?
Upvotes: 0
Views: 1316
Reputation: 5438
Another way to do it is to use setInterval
function like below :
Creating an interval
var ResInterval = window.setInterval('myAjaxCall()', 60000); // 60 seconds
var myAjaxCall = function() {
$.ajax({
type: "GET",
url: options.feedUrl,
dataType: "xml",
async:options.sync,
success: function(xml) {
// todo
}
};
To stop
window.clearInterval(resInterval);
Code taken from the below link:
How do I make Ajax update every 10 seconds in jquery?
Upvotes: 1