Reputation:
Righteo, Just started messing with Jquery, and I can update a database etc with it, but I want to know if there is a way to display new info posted into a database (even if it is not what was just posted) without a reload etc.
Don't write it out for me, just point me in the right direction... I want to pull it together myself.. best way to learn :D
Upvotes: 2
Views: 2160
Reputation: 524
var dataString="variable="+variablevalue;
// Check if there is any updates every 3 second.
var x=setInterval(doUpdates,3000);
function doUpdates() {
$.ajax({
type: 'POST',
url: "yourfile.php",
data: dataString,
success: function(data) {
$('#yourid').html(data)
//This will update the HTML code.
}
})
Upvotes: 1
Reputation: 14468
The only way is to have the web page regularly poll the server for new info.
There is no way to initiate interaction from the server side.
Edit:
No way except to use a framework that handles the polling for your.
Upvotes: -1