|
-
December 19th, 2006, 10:10 AM
#1
Update DIV without updating the whole page
I want to do a function like Digg Live. I have a file that prints out the latest 10 rows in my database. And everytime a new entery is added to the database, I would like the DIV to be printed out like it does on Digg Live.
I've read about HTTP requests but I still don't have a clue what to do.
Can someone help me with this, or point me in the right direction. Maybe you know a tutorial or a premade script that looks something like this.
Thanks in advance / Media12
-
December 19th, 2006, 10:50 AM
#2
Re: Update DIV without updating the whole page
The Digg live link that you have is invalid. Do you have a better link.
Concerning writing dynamically to a <div> just change the innerHTML content.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
December 19th, 2006, 03:33 PM
#3
Re: Update DIV without updating the whole page
Ah I'm sorry it should be www.digg.com/spy/
-
December 19th, 2006, 04:10 PM
#4
Re: Update DIV without updating the whole page
It's just dynamically writing div content. It is the same as doing...
Code:
document.getElementById('div_id').innerHTML = content + document.getElementById('div_id').innerHTML;
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
December 19th, 2006, 04:15 PM
#5
Re: Update DIV without updating the whole page
Actually, the revelant "magic" revolves around (and similar constructs):
Code:
timer2 = setTimeout('update()', updateDelay);
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
December 19th, 2006, 05:24 PM
#6
Re: Update DIV without updating the whole page
Well, you wouldn't want setTimeout(), you would use setInterval() for a reoccurring event.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
December 19th, 2006, 05:32 PM
#7
Re: Update DIV without updating the whole page
Hey I just looked at the source code of the referenced page....
While I agree that SetInterval is a better design (usually), SetTimeout can also be used (you just have to set the timeout inside of the invoked function to make it repeat).
Also SetTimeout will control the time between the end of call #n and the start of call #n+1. SetInterval will control the time between start #n and start #n+1. If there is a possibility of execution(x)>interval(x), then this design pattern can prevent stacking or recursive calls.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
December 19th, 2006, 07:18 PM
#8
Re: Update DIV without updating the whole page
 Originally Posted by TheCPUWizard
While I agree that SetInterval is a better design (usually), SetTimeout can also be used (you just have to set the timeout inside of the invoked function to make it repeat).
Yes, but it is slower in its response time and more CPU intensive.
 Originally Posted by TheCPUWizard
Also SetTimeout will control the time between the end of call #n and the start of call #n+1. SetInterval will control the time between start #n and start #n+1. If there is a possibility of execution(x)>interval(x), then this design pattern can prevent stacking or recursive calls.
This is true, but also remember that setInterval() is not meant to execute heavy code on a high-rate interval.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
December 19th, 2006, 10:06 PM
#9
Re: Update DIV without updating the whole page
Which is why the "correct" solution could very much be application specific
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|