jquery auto refresh div content example

60

jQuery load method requests server pages and refreshes HTML selector with the page content. In this tutorial, we are going to auto load and refresh a DIV with a periodic interval.

This jQuery auto load tutorial will help to refresh content with very latest feeds, to load random advertisement banners and etc.

jQuery Auto Load

Very few lines of code are required for the jQuery auto load. And it is,

The PHP file banners.php is requested via jQuery ajax using load method. This file contains an array of HTML color codes. One of those colors is picked using PHP array rand to change banner backgrounds and loaded into a specified DIV. The PHP code is,

This jQuery load event happens every 2 seconds to update the banner periodically. Instead of using static array data we can connect DB to load div with dynamic data.

Leave A Reply

Your email address will not be published.