Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Updating php page every second without refreshing

Posted on 2011-02-22
3
Medium Priority
?
702 Views
Last Modified: 2013-12-13

I have a php page which loading data from MySQL database. I try to make that this page updating automatically every few second without phprefreshing.
0
Comment
Question by:sam20
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
jason987 earned 2000 total points
ID: 34955381
You'll probably want to use ajax.  Here is some discussion/code on how to reload based on timers, just modify to fit your use:

http://www.webdeveloper.com/forum/showthread.php?t=169337

http://www.brightcherry.co.uk/scribbles/2009/02/26/jquery-auto-refresh-div-every-x-seconds/
0
 

Author Comment

by:sam20
ID: 34955622
Hi
thanks for you answer, this code works but goes back to last data again after about a second
<html>
<head>
<!-- For ease i'm just using a JQuery version hosted by JQuery- you can download any version and link to it locally -->
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
 $(document).ready(function() {
        $("#responsecontainer").load("response.php");
   var refreshId = setInterval(function() {
      $("#responsecontainer").load('response.php?randval='+ Math.random());
   }, 9000);
});
</script>
</head>
<body>
 
<div id="responsecontainer">
</div>
</body>
0
 

Author Closing Comment

by:sam20
ID: 34955901
Thank you, the first link works fine.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question