?
Solved

Updating php page every second without refreshing

Posted on 2011-02-22
3
Medium Priority
?
699 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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

719 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