1,105,534 Community Members

How to refresh webpage data without reloading whole page

Member Avatar
butler1233
Newbie Poster
7 posts since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi guys

Im wondering how it is possible to refresh the data on the page (read from php database), without having to refresh the whole page.

What i want i something similar to facebook and twitter, where it will say that new stuff has appeared. Instead of this though, i want it to just appear, instead of a box coming up with it appearing.

Instead of some messed up hard to understand guide, I would like a simple to understand, straight forward guide on how to do this,

Thanks guys.
-Butler

Member Avatar
weekendrockstar
Junior Poster in Training
71 posts since Dec 2010
Reputation Points: 12 [?]
Q&As Helped to Solve: 16 [?]
Skill Endorsements: 0 [?]
 
0
 

The following page gives an example: http://www.brightcherry.co.uk/scribbles/jquery-auto-refresh-div-every-x-seconds/. It uses JQuery which you can download from their official site http://jquery.com/. You can download the latest package, upload it to your site and change the location of the jquery .js file in the example. You may be able to use the "latest version" method that the example uses if JQuery still supports it.

<div id="responsecontainer">
</div>

You can change the name of the div's ID if you so choose but if you do change it then you need to change the two places in the code below where the div's ID is specified to match what you name the ID above.

<script>
 $(document).ready(function() {
 	 $("#responsecontainer").load("YourScript.php");
   var refreshId = setInterval(function() {
      $("#responsecontainer").load('YourScript.php');
   }, 9000);
   $.ajaxSetup({ cache: false });
});
</script>

Change the "YourScript.php" to the file which does the database querying and prints it out as you wish.

Read the first link for more details on the time until automatic refresh.

This will make whatever YourScript.php outputs available on the page load and then automatically refreshes it at the time you state for as long as the visitor remains on the page.

Question Answered as of 2 Years Ago by weekendrockstar
teraro
Newbie Poster
1 post since Oct 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

how to add loading gif at beging?

rootoa
Newbie Poster
1 post since Oct 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 
        How to load Whole page without Refreshing It.
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: