jQuery DIV Auto Load and Refresh

Home >> Blog >> jQuery DIV Auto Load and Refresh

jQuery DIV Auto Load and Refresh - jQuery Reload DIV

jQuery load() Method

Description: Load data from the server and place the returned HTML into the matched element.

Syntax: .load( url [, data ] [, complete ] )
  • url
    Type: String, A string containing the URL to which the request is sent.
  • data
    Type: String, A plain object or string that is sent to the server with the request.
  • complete
    Type: Function( String responseText, String textStatus, jqXHR jqXHR )
    A callback function that is executed when the request completes.
$(document).ready(function() { setInterval(function() { $("#mydiv").load('load_data.php') }, 5000); });
  1. The PHP file load_data.php is requested via jQuery ajax using load method.
  2. The above code will run every 5 seconds and will update data in div with ID- mydiv
You may also like - JavaScript Interview Questions [Advanced]