Jump to content

Need to poll server?


JohnOP

Recommended Posts

I have a comment type of system that i am building which is using jquery to post the comments.

 

When posting a new comment, the div that holds all the comments gets the new post added to it without page refresh which is all good and how i want it. I noticed though if i sign in to my website on another computer and am on the same page as the comments, only the one whom posted the comments div will update because its only them who are firing the form so any other user would have to refresh the page to see the new comment.

 

 

<script type="text/javascript">
$('form[name=feedUpdate3]').submit(function(){
                var id = <?php echo ($id) ?>;
			var share = $('.expand'+id).val();
			var post_id = $('.post_id'+id).val();
			$.post('updateFeeds.php', { share: share, post_id: post_id }, function(data){
			$('#show_comments'+id).load('post_comments.php?post_id='+id);
        });
</script>

 

#show_comments is the comments div

 

I have a working solution which is to poll the comments div every so many seconds so all users would get updated with any new comments without having to refresh the page though i know that would cause heavy load on the server. I am just looking for another solution to this.

 

Link to comment
https://forums.phpfreaks.com/topic/260370-need-to-poll-server/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.