Welcome to WebmasterWorld Guest from 107.22.7.35

Forum Moderators: open

Message Too Old, No Replies

display text with delay

     
1:03 pm on Aug 5, 2011 (gmt 0)



Hi,

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.
1:52 pm on Aug 5, 2011 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



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").
 

Featured Threads

Hot Threads This Week

Hot Threads This Month