Computer Science Canada Dynamically updating page layout |
Author: | DanShadow [ Wed Sep 22, 2010 2:00 pm ] |
Post subject: | Dynamically updating page layout |
Hey all. I was wondering if anybody knows anything about dynamically changing the format of a web-page? Specifically, i'm trying to make it so a web-page will update displayed variable data (or change a page state & layout) when a trigger occurs (such as a change in an element in a database or file), but a trigger that may not be initiated by the user. Ex. Two users are interacting using two instances of a web-page, but with data being shared by using a file/database. When one user presses a button, the second user has something (like a graphic) on their instance of the web-page show them that the first user had pressed that button. I was originally thinking of using an timed HTTP page refresh, but im sure there has to be a much better way. Anybody have any thoughts on this?? Thanks! |
Author: | DanShadow [ Wed Sep 22, 2010 7:58 pm ] |
Post subject: | RE:Dynamically updating page layout |
I'm figuring AJAX is my best bet rather than relying on PHP. |
Author: | Amailer [ Wed Sep 22, 2010 8:01 pm ] |
Post subject: | RE:Dynamically updating page layout |
I recommend you use jQuery as its very simple to use (http://jquery.com/). I'm guessing a simple way is to write a server side script to check for the change in the DB- if it has occured make it return a simple "true" else just "false. Then make a client side script to check that script every X interval, if it gets a "true", then make your client-side changes (it will display live). With jQuery, create a function that utilizes jQuery.ajax (http://api.jquery.com/jQuery.ajax/) and in the success callback function do a check; If false, rerun the ajax call, else if its true, then make your client-side notification. There are probably better ways but I myself am new to AJAX but I had to do something like this before and that's how I did it. |
Author: | DanShadow [ Wed Sep 22, 2010 8:59 pm ] |
Post subject: | RE:Dynamically updating page layout |
Thanks, that should help. Just really looked into Ajax today, and it seems like a very useful way to make a dynamic web-page. Refreshing pages just looks unattractive =/ |