Talha Habib Talha Habib - 4 months ago 7x
jQuery Question

refresh container without refreshing page

By using this

<?php echo date('r'); ?>
, is there any way i can refresh simple container (span where my time is echo) without refreshing the page Here this is my page i am displaying date and time here


Send AJAX request periodically to a PHP file which echos date.

(function worker() {
    url: 'backend.php', 
    success: function(data) {
    complete: function() {
      // Schedule the next request when the current one's complete
      setTimeout(worker, 5000);

Call this worker() function on the div of the date.


echo date('Y-m-d H:i:s'); // This is just a sample date format. YOUR DATE FORMAT.