homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

display text with delay

Msg#: 4348212 posted 1:03 pm on Aug 5, 2011 (gmt 0)


Does someone have an working example of the following:

Select records from a database, display the first 10, and after 30 seconds, display the next 10 without refreshing the page.
Then, when no more records, start over.

Can this be done? I've been looking for jquery etc but didn't find anything.

Please help.



WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member

Msg#: 4348212 posted 1:52 pm on Aug 5, 2011 (gmt 0)

Welcome to WebmasterWorld!

Anything database related is going to require server side code to interact with the database (php, etc.). You can't communicate directly with a database using JavaScript, but you COULD communicate with a page on the server (which in turn communicates with the database).

You don't actually need jQuery for this, though it can make the AJAX [api.jquery.com] and DOM updating pieces a bit easier. The 30 second piece can be accomplished using setInterval or setTimeout. For example:

setInterval(getNext10Records, 30000); // 30000ms = 30 seconds
function getNext10Records() {
// send AJAX request to the server
// replace a section of the page with contents of AJAX response

You would probably need to keep track of an "index" to identify which records were currently shown, and pass that to your server page so that it can accurately determine the next records to show (note, if there is any security concerns, then you would not want to control that on the client side... for example, if you don't want someone to be able to "jump ahead").

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved