Reputation: 663
My friend and I maintain a submission site with comments. We want to know if it is possible to have a constant AJAX connection. Basically, each submission has a comments section. My friend had an idea of having an alert appear on the page everytime a new comment came in. So, would it be possible to keep up a constant link between the AJAX object and a PHP script that queries the comment database? If so, how? If not, is there another way to do it?
Upvotes: 0
Views: 643
Reputation: 32888
this could be an option this worked for me.
<a href="javascript:;" onclick="$('#mycomments').load('http://s.bla/rpc.php?qry=11',
function(){$('#mycomments').show('slow');});">Comments</a>
<div id="mycomments" style="display:none;">
Comments
</div>
Upvotes: -1
Reputation: 7960
Sounds like you are describing Comet.
Alternatively, most sites that do that kind of thing just make a query to the server every so often asking if anything new has been posted (need to make sure you pass in a timestamp of the last time you checked).
Upvotes: 7