To use this website completely, it is necessary to store cookies on your computer.
 

* Navigator

Expand - Collapse

* Statistic

  • *Total Posts: 16403
  • *Total Topics: 2518
  • *Online Today: 8
  • *Most Online: 292
(12. Nov 2016, 09:37:31)
  • *Users: 0
  • *Guests: 0
  • *Spiders: 1
  • *Total: 1

  • *Yahoo!

Ajax recent posts.

Started by laric, 30. Mar 2009, 09:58:48

previous topic - next topic

0 Members and 0 Guests are viewing this topic.

Go Down

laric

30. Mar 2009, 09:58:48
I have started to use a little ajax on my frontpage to make more of the frontpage auto refresh.

Here is a sample recent posts block that I use.


"$(document).everyTime(300000, function(i) {  updateLastposts();}, 0);" controls how often the block is autorefreshed.


This uses jquery and jquery.timers

http://www.jquery.com and http://plugins.jquery.com/project/timers

Put this in a script block
Code Select

<div id="latestpostsajax" class="content"></div>
<script type="text/javascript" src="/jquery-1.3.min.js"></script>
<script type="text/javascript" src="/jquery.timers.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var messageList = $("#latestpostsajax");

function updateLastposts(){
messageList.hide();
$.ajax({
type: "POST", url: "/recentposts.php", data: "action=update",
complete: function(data){
messageList.html(data.responseText);
messageList.fadeIn(2000);
}
});
}

updateLastposts();

$(document).everyTime(300000, function(i) {  updateLastposts();}, 0);
});
</script>


Put this in /recentposts.php
Code Select

<?php 
require("SSI.php");
$myarray ssi_recentTopics(5null'array');
global 
$settings
foreach (
$myarray as $value) {
    echo 
"{$value[link]}<br/>".($value['new'] ? '' '<a href="' $scripturl '?topic=' $value['topic'] . '.msg' $value['new_from'] . ';topicseen#new" rel="nofollow"><img src="' $settings['lang_images_url'] . '/new.gif" border="0" /></a> '
.
"by {$value[poster][link]}<br/>{$value[time]}<br/><hr />";
}
 
?>
 


laric

#1
03. Apr 2009, 18:35:10
I have done my own shoutbox instead of the one provided by portamx.

Guess I could clean up the spaghetti code and post it here.

I might do this over the easter holiday.

bancherd

#2
04. Apr 2009, 02:00:21
Thanks...looking forward to it.  :)

Dylert

#3
23. Aug 2013, 01:45:28
Quote from: laric on 30. Mar 2009, 09:58:48
I have started to use a little ajax on my frontpage to make more of the frontpage auto refresh.

Here is a sample recent posts block that I use.


"$(document).everyTime(300000, function(i) {  updateLastposts();}, 0);" controls how often the block is autorefreshed.


This uses jquery and jquery.timers

http://www.jquery.com and http://plugins.jquery.com/project/timers

Put this in a script block
Code Select

<div id="latestpostsajax" class="content"></div>
<script type="text/javascript" src="/jquery-1.3.min.js"></script>
<script type="text/javascript" src="/jquery.timers.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var messageList = $("#latestpostsajax");

function updateLastposts(){
messageList.hide();
$.ajax({
type: "POST", url: "/recentposts.php", data: "action=update",
complete: function(data){
messageList.html(data.responseText);
messageList.fadeIn(2000);
}
});
}

updateLastposts();

$(document).everyTime(300000, function(i) {  updateLastposts();}, 0);
});
</script>


Put this in /recentposts.php
Code Select

<?php 
require("SSI.php");
$myarray ssi_recentTopics(5null'array');
global 
$settings
foreach (
$myarray as $value) {
    echo 
"{$value[link]}<br/>".($value['new'] ? '' '<a href="' $scripturl '?topic=' $value['topic'] . '.msg' $value['new_from'] . ';topicseen#new" rel="nofollow"><img src="' $settings['lang_images_url'] . '/new.gif" border="0" /></a> '
.
"by {$value[poster][link]}<br/>{$value[time]}<br/><hr />";
}
 
?>
 



Is it still possible to use this? The post is written in 2009 and it would have been lovely to have an Ajax version of Recent topics! :)

Go Up