Server Real Time on Website - real-time

I would like to grab the time (something like): 16:08 from the server - and display it on the website real time. (Like, each minute do the update, and display the new time.
I'm not sure however, what would be a good way for accomplish this nor if there is any nice plugin that I should be aware of. :D
Can I have some insights about the possibilities here?
I'm using PHP and I can use Jquery as library.
Thanks a lot,
MEM

Use Javascript and set a timer for every minute. Have the timer call a function that uses Ajax to call the correct page on the time server which gets the time and then have the Javascript replace the existing time.
You could also just get the actual time from the server when you load the page, then use Javascript to increment the minute/hour section appropriately by using a timer that 'ticks' every minute.

If the problem is just to display the time you can use Date.getTime() javascript function.
But if you want to get the time from the server and display it to the client you can use an ajax request using JQuery.

Related

How to redirect after some time in Play Framework? - SCALA

I have a following problem. When someone enters my index page, I would like them to see it for a while (let's say 2 seconds) and then be redirected to another page. What is the best way to do it in Play Framework? (I tried using WS.url().get as well as calling a method which return Ok - both without any result)
You'll need to use JavaScript/HTML for that. Play will allow you to do server side redirects, which will be instantaneous, for a delay it has to be done client side.

how to show eclipse console in my jsp page?

I have a method in action page, it will take more time to execute so I have write some description on console window. But now i want to show the description on text area in jsp page. how to show like as console.
Two possible solutions are the "execAndWait" interceptor and using ajax.
Execute and Wait will be the easier to implement but will present less functionality...
http://struts.apache.org/2.3.4.1/docs/execute-and-wait-interceptor.html
Ajax can provide continuous feedback of the state of the request (although managing that feedback is entirely up to you and it will typically require you to think in terms of services, one page will typically make use of multiple services).
For this you will not have to worry about the amount of time it takes your action to return because it is being called asynchronously. You could even make a queue showing how many request you've sent and pop them off as they are received.
To implement ajax services it is easiest to start with json and for that see the struts2-json-plugin http://struts.apache.org/2.2.3/docs/json-plugin.html

iphone consume wcf once every minute

My app is able to consume a wcf using ASIHTTPRequest. But the thing is that i need to check the server hour every one minute. So i need a request to the server every one minute. What is more, sometime i will need to refresh the clock every one second.
the app is a items auction so i need to get the hour no matter what.
so my question is, is this going to kill the iphone?
ASIHTTPRequest have a method to achieve this? making calls every XX time?
some good way to do it?
Thx in advance!
Assuming the data you are getting back isn't larger than the memory threshold, and you are properly managing memory on your end, AND you are performing an asynchronous request (or a request on a background thread), this shouldn't kill the app memory-wise or cause it to hang.
I do something similar, where every 2 minutes I ping my server for updates. I achieve this using an NSURLConnection and NSURLRequest, though I imagine ASIHTTPRequest is not much different. I typically use a recurring timer that, when invoked, calls a method which, using Grand Central Dispatch, sets up my request/connection and fires.

Navigating to a different page based on a timer in MVC2

I was hoping that I could be able to send a user to a different page if they have not executed any functions in a certain time frame. Is there some kind of timer that I can execute to accopmlish this?
Thanks,
Derek
You could use the jQuery idle plugin.

How does the Notice Area on Facebook works?

How does the notification area on Facebook works?
I'm taking about the automatically red box that appears.
If I have a message/something new on my wall.
I believe it is also in Stack Exchange, is that a Javascript interval?
Please see this thread
How does one do realtime updates of a web page?
Not sure about this, but I'd wager that both Facebook and SO use an implementation of Comet. Basically, you make a request to the server which is designed to be kept open a really long time, and the server only responds when it has something to say. When the request times out (or receives data back) you simply start up another one. This way you get as close to real-time data as you can without wasting a ton of bandwidth on empty requests.