javascript - Using ajax to pass time in seconds to div -
i'm trying use ajax pass time in seconds div div id of 'seconds', reason it's not passing div. please take @ code:
testing1.php
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script type = "text/javascript"> function timeoutajax(url,id,timeout) { $.ajax({ type: "post", url: url, error: function(xhr,status,error){alert(error);}, success:function(data) { document.getelementbyid( id ).innerhtml = data; settimeout(function() { timeoutajax(url,id,timeout); }, timeout); } }); } timeoutajax("testing2.php","seconds",1000); <div id = "seconds"></div> </script>
testing2.php
<?php $date = date("s"); echo $date; ?>
put div after closing script tag.
</script> <div id = "seconds"></div>
Comments
Post a Comment