Jump to content

Recommended Posts

  • Administrators
Posted

I'm trying to find a good tutorial on how to create a spot on my website that will pull in data from a mysql table and auto update without reloading the page. Something very similar to the funtionality of Facebook's News Feed. I can't seem to find anything. Anyone know of any good tutorial on how to accomplish this in PHP?

  • Administrators
Posted

No one huh? I still haven't found a thing about it online. I maybe searching the wrong things though.

Posted (edited)

Its just basic AJAX.

 

So at the front end you use js via ajax to pull the data and then render it.

 

At the back end you just return the data from mysql query.

 

I'll post later some code examples if you want.

Edited by __Darknite
  • Administrators
Posted

I got it!

 

Ended up using this tutorial, made it real simple. You just keep the portion that needs refreshed in your response.php file and then html in you main .php file that the user hits.

 

This is the javascript code that you put in the beginning of the page:

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

 

 

This div is in your main .php file the user goes to wherever you want to put it, it will be the div that is refreshed

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

 

Now after you have that setup, just drop your code you need to be refreshed in your response.php file and wala!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...