Reload a php include every 5 minutes

wright

Newbie
Oct 1, 2017
6
0
0
I'm programming with php, and I do not know of Jquery. 

Inside my page I make an include ('show.php'); 

I need this to be reload every 5 minutes without updating the page. 

Incorporate the same Jquery in this way
Code:
<script src = "jquery-3.2.1.min.js" type = "text / javascript"> </ script>
and then in the body I call the file this way
Code:
<div class = "example"> 
 <ul class = "nav"> 
<? php include ('show.php'); 
 </ ul> 
</ div>
Thanks in advance.
 

edwin

Newbie
Sep 28, 2017
35
2
8
the php is executed only once on the server and ready, after sending the client the execution is finished, there is nothing else you can do with it ...

for what you want there are 2 possibilities

one is iframes another is ajax
-iframe is a web page inside another, like a window, there you can load instead of include, the file of this, and you can add it as a header to be updated every 5 min

-ajax is a cross-technique where you call php with a jscript
 

wright

Newbie
Oct 1, 2017
6
0
0
edwin said:
the php is executed only once on the server and ready, after sending the client the execution is finished, there is nothing else you can do with it ...

for what you want there are 2 possibilities

one is iframes another is ajax
-iframe is a web page inside another, like a window, there you can load instead of include, the file of this, and you can add it as a header to be updated every 5 min

-ajax is a cross-technique where you call php with a jscript
That's what I was finding out, but I did not get the JQuery code to do it, over I change the way to do the load in 3.1
 

edwin

Newbie
Sep 28, 2017
35
2
8
Code:
Code:
 < div  id = "receiver" > here the data will be updated < / div >
Code:
Code:
$ (  "#receptor"  ) . load (  "pageload.php"  ) ;
or do it with a timeout or similar
 

wright

Newbie
Oct 1, 2017
6
0
0
edwin said:
Code:
Code:
 < div  id = "receiver" > here the data will be updated < / div >
Code:
Code:
$ (  "#receptor"  ) . load (  "pageload.php"  ) ;
or do it with a timeout or similar
It worked for me, now I should get the timeout.
 

edwin

Newbie
Sep 28, 2017
35
2
8
Code:
Code:
 setInterval ( function ( ) {  // call as an anonymous function to summarize
  $ (  "#receptor"  ) . load (  "pageload.php"  ) ;
} ,  1000 * 60 * 5 ) ;  // 1000 milliseconds per second, 60 seconds per minute, 5 minutes
this should suffice
 

wright

Newbie
Oct 1, 2017
6
0
0
edwin said:
Code:
Code:
 setInterval ( function ( ) {  // call as an anonymous function to summarize
  $ (  "#receptor"  ) . load (  "pageload.php"  ) ;
} ,  1000 * 60 * 5 ) ;  // 1000 milliseconds per second, 60 seconds per minute, 5 minutes
this should suffice
Thank you very much, it works perfect.
 

Helsa

Newbie
Sep 17, 2014
17
0
0
Usually that is a bad practice, what you should do is go to search the data with ajax and modify the data dynamically on the website from javascript or if you want to deploy information in real time you must use websockets.
Code:
 http://www.phpbuilder.com/articles/application-architecture/optimization/creating-real-time-applications-with-php-and-websockets.html
 

wright

Newbie
Oct 1, 2017
6
0
0
Helsa said:
Usually that is a bad practice, what you should do is go to search the data with ajax and modify the data dynamically on the website from javascript or if you want to deploy information in real time you must use websockets.
Code:
 http://www.phpbuilder.com/articles/application-architecture/optimization/creating-real-time-applications-with-php-and-websockets.html
Friend, Thank you very much. I solved it with the previous help, but I'll read about what you recommended. 

As a comment I add that what I charge is a table made with php and mysql, and I still do not know ajax but I will start to study it.
 

Advertisement

Top