Solved

Updating php page every second without refreshing

Posted on 2011-02-22
3
690 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 500 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now