keep showing post result

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
pedroz
Forum Commoner
Posts: 99
Joined: Thu Nov 03, 2005 6:21 am

keep showing post result

Post by pedroz »

This code works and shows the time

Code: Select all

<script type="text/javascript">
	jQuery(document).ready(function(){
	jQuery("#show_more").click(function(){		
		
		var rel = jQuery(this).attr("rel");			
		var data = {
			action: 'more',
			rel: rel
		};
		jQuery("#read_more").html("loading...");
		jQuery.post("time.php", data,
		function(response){
			jQuery('#more').html(response);
		});
		return false;		

		});
	});
</script>

<div id="more"></div>

<a id="show_more" href="" rel="2">show more</a>
file time.php
[syntax]<?php

echo time().'<br />';

?>[/syntax]


Result is the following if clicking show more link
ie
1307461931
show more

How can I have keep the previous time and add one to the list, basically would be showing the following?
1307461931
1307461940
1307461972
show more

Every time I click show more, it would add a time to the list
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: keep showing post result

Post by Celauran »

pedroz
Forum Commoner
Posts: 99
Joined: Thu Nov 03, 2005 6:21 am

Re: keep showing post result

Post by pedroz »

Found it! Thank you very much for the tip... ;)

jQuery('#more').append(response);
instead of
jQuery('#more').html(response);


Let me ask you this, if you could and it is possible.

Imagine the file time.php has a limit

Code: Select all

<?php

echo time().'<br />';

// if (time() > 1307463951) $not_show_more_link = 1;
?> 
Is it possible to hide "show more" link if time.php reports a response to hide it?
Post Reply