continuous - php do something with interval -
i have form, :
<form name="form1" action="" method="post"> <input type="text" name="tfcari" /> <input type="submit" name="btcari" /> </form> <?php if (isset($_post['btcari'])) { echo $_post['tfcari']; ?>
how doing :
click submit - echo text - wait 5 seconds - echo text (automatically) - wait 5 seconds - echo text (automatically) - ...
thanks all.
php pre-processes before sending website, if put sleep method, delay page frrom displaying long.
the -easiest- way use jquery ajax call, use settimeout echo text every 5 seconds:
// assuming jquery linked $(function() { // connect php file $.ajax({ url: 'php-file-with-tfcari-var.php', type: 'post', success: function(data) { // data ajax call returns, let's assume it's $_post variable php var tfcari = data.tfcari; // can loop every 5 seconds self calling settimeout method var poll = (settimeout(function() { window.document.write(tfcari); }, 5000)(); } }); });
Comments
Post a Comment