Hi everyone,

For a social system I am working on, I am in desperate need of being pointed in the right direction for how to create a live ajax feed which calls data from a database.

Urgently needed, any help much appreciated!



Recommended Answers

All 3 Replies

Look here:


Depending on how often you want your feed to be updated you could use a Javascript setInterval() function to repeatedly call the .load ajax feed.

Here is something I've used in the past (to update a price of an item every couple of seconds).

<!DOCTYPE html>
<script type="text/javascript">
function updateBids() {
	var url="getprice.php?auc=<?php echo $id; ?>";
	jQuery("#priceElement")<strong class="highlight">.load</strong>(url);

<strong class="highlight">setInterval</strong>("updateBids()", 1000);
Here is the price: <div id="priceElement"></div>

Simple (behind-the-scenes) PHP script to fetch data from db:


// Anything printed on this page will be loaded into the priceElement <div>

                include ('db.php');

		$id = $_GET['auc'];
		$getprice = mysql_query("SELECT b_currentprice FROM bid WHERE auction_id = '$id' ORDER BY b_timestamp DESC");
		$resultprice = mysql_fetch_assoc($getprice);
		$price = $resultprice['b_currentprice'];
		echo $price;

Cheers for that I modified the jquery slightly and altered it to work with my existing php calling script, and it works awesomely!


is it same as?:

setInterval(function() {
}, 500);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.