Automatically Load Content and Refresh Div Using jQuery

Good Morning Guys,
Automatically reload and displaying the content without reloading the page is very important in web application. Specially this technique is used in news or magazine website for latest news, organization website, banking site for notification etc. You can directly display content in your website from database and automatically change it after fixed interval of time. There are times when you need to refresh some part of your web page in a specific interval of time (I recommend three seconds).




This tutorial teaches you how to load contents from an external page or file into your current page and refreshes these contents every 3 seconds with the help of PHP and Jquery.

Let’s see how you can achieve this:

Main part of this tutorial is the jQuery code. This is very simple:





datas.php file is responsible for what data is to be displayed.
You can either fetch data from any file or database tables.

Code for datas.php




Secure Login page using PHP and MYSQL based on user role
";
$i_2="
  • Ajax Upload and Resize an Image with PHP
  • "; $i_3="
  • Facebook Style Background Image Upload and Position Adjustment
  • "; $i_4="
  • How to Manually Reset Your WordPress Admin Password
  • "; $i_5="
  • Create Simple But Secure Registration form in PHP using PDO
  • "; $display_content = array( $i_1=>1, $i_2=>2, $i_3=>3, $i_4=>4, $i_5=>5 ); print_r(array_rand($display_content,1)); ?>




    Code for index.php

    
    
    Automatically Load Contents and Refresh Div using Jquery and Ajax
    
    
    
    
    
    

    Automatically refresh div using jQuery -PrittyTimes




    If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.