Jump to content


news ticker? i guess?


1 reply to this topic

#1 er0x

    Young Padawan

  • Members
  • Pip
  • 43 posts

Posted 06 October 2009 - 11:45 PM

ok so i have a project for work and i kinda dont know where to get started on it.

i need a news ticker. sort of like a rss feed but what i put in the database.

i need it to update every 10 seconds and sort through the last 10 entries from a database.

can you help point me in a direction with the updating every 10 seconds?

#2 Neil

    Past Staff Member

  • Members
  • Pip
  • 149 posts
  • Gender:Male
  • Location:Australia

Posted 07 October 2009 - 03:20 AM

So it has to update in the user's browser every 10 seconds?

Install jquery and do something like:
$(document).ready(function()
{
// Update the news every 10000 microseconds (check the doc to see how many seconds this is)
setInterval(update_news, 10000)

update_news();

});

function update_news()
{
$("#news").load("/news/");
};

Now this add a div on your website like: <div id="news">Loading...</div>

Once the page is rendered it will place all the html from /news/ into that div.

I didn't test any of that syntax so I can't 100% guarantee it would work, but its a start.

cheers

References:
http://docs.jquery.c...nloading_jQuery
http://docs.jquery.com/Ajax
http://docs.jquery.c...urldatacallback

Edited by Neil, 07 October 2009 - 03:19 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users