- Auto Load Contents and Refresh Div Every 10 Seconds via Ajax and jQuery. There are times when you need to refresh some part of your web page in a specific interval of time. For instance: Shared market updates, Users Online etc. In cases like these, you may need to refresh a part of your web page without reloading the entire content on your page.
- Ajax Update Div Every 5 Seconds. 7/20/2017 0 Comments Tutorial (ASP. If you like, you can see the tutorial for ASP. NET Core instead.
Index.html
The above script will display the element after 3 seconds of loading the webpage. Hide method will hide the text Hey this is saruque at first. Then delay method will create a delay. We can pass time as the parameter here. Here we put 3000 for creating a delay of 3 seconds. FadeIn (‘slow’) is optional.
This contains html and javascript code. load('load_post.php');
2 4 6 8 10 12 | varautoLoad=setInterval( { $('#load_post').load('load_post.php').fadeIn('slow'); </script> <body> <div id='load_post'></div> |
Load_post.php
This contains php script to get data from the database.
Update Div Every 5 Seconds Chart
2 4 6 8 10 12 | include_once('config.php'); $sql=mysql_query('SELECT * FROM tblpost LIMIT 0, 5')ordie(mysql_error().' Error loading data.'); $num_post=mysql_num_rows($sql);// count the number of rows // check if there is data //this contains data to load into a page. echo'<p>There are no added post yet, please try to add to start sharing.</p>'; |
Html Refresh Div Every 5 Seconds
This is very helpful if you want to get and load data from database in every x seconds without refreshing your page.