Click to See Complete Forum and Search --> : Update div from the server every 1 sec


fatnjazzy
06-10-2007, 11:10 AM
hi,
I am working on a forex website.
in every forex website there is currency quotes box that refresh itself every 1 seccond and display the new currency price.
Most of the website use java for that.
im not a java programmer so i cant do that....
i thoght about the option to do it in ajax...
all i did is bring some numbers from the server every 1 seccond.
That browser stopped functioning.

can anyone give me an example of how to do it in the most efficient way?

here is an example of a currency box in java.
http://www.forexwebtrader.com/tools/currencies.php
(it doesnt change on the weekend because there are no trades)

Thanks in advanced

miramardesign
06-10-2007, 12:39 PM
I used sajax (http://www.modernmethod.com/sajax/)in the last ajax app that I did, It took more js knowledge than php and I had to brush up on my js-fu for a couple of days to get it working but it was an adventure. :)

Others recommend xajax but I have yet to try it, I might do so in the next project that calls for ajaxification that I do.

miramardesign
http://miramardesign.com
I code therefore I am.

nemonoman
06-10-2007, 01:29 PM
A simpler approach would be to put the quotes box in an iframe. Set the source of the iframe to a page that refreshes (google meta refresh) every second. If you really need a div, you can put the iframe in a div
<div><iframe borders=no src=http://myserver.com/pagethatrefresheseverysecond.html></iframe></div>

bpat1434
06-10-2007, 05:22 PM
The problem with this is that you can not (unless using extremely fast equipment) have page send a request, the server handle, and receive the request every second. Well, I shouldn't say "can not" but rather most likely won't. You've got to worry about server load, what's being served (static or dynamic) and how long it takes to process that page? I.e. if you're refreshing the output of a php file, then how long does it take for the server to serve that on its own? If it takes the server longer than 1 second to parse the PHP file, there's no reason to refresh every second (seeing as how you'll never get output) ;)

Do some benchmarking first to see how long on average the page takes to load. Then add a few seconds to account for server load. My guess is every 10 seconds is pretty good, although you could probably get away with every 5.

fatnjazzy
06-12-2007, 07:46 AM
Hey bpat1434,
that was the problem, i called the ajax object before it supplied the previous data.
Thank You!

bpat1434
06-12-2007, 09:30 AM
No problem. Don't forget to mark this thread resolved