jQuery DIV Auto Load and Refresh
jQuery DIV Auto Load and Refresh - jQuery Reload DIV
jQuery load() MethodDescription: Load data from the server and place the returned HTML into the matched element.
Syntax: .load( url [, data ] [, complete ] )-
urlType: String, A string containing the URL to which the request is sent.
-
dataType: String, A plain object or string that is sent to the server with the request.
-
completeType: 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);
});
- The PHP file load_data.php is requested via jQuery ajax using load method.
- 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]