views:

26

answers:

1

Hello,

I have a php script on my site (users_online.php) that shows how many people are connected to my server whenever the script is executed and I would like to display and update this information on my front page using javascript / ajax without refreshing the page is this possible ?

Thanks, Kelly

+1  A: 

Yes, its certainly possible. You can use jquery or any of the other myriad of js libraries out there.

The process is

  1. fire an xml http request (XHR) with whichever library you choose.
  2. process the response (handle both success and failure)
  3. update your page by dynamically modifying the DOM with your results.
hvgotcodes
@Spinon I haven't tried anything yet because I just wanted to know if it was possible or not first.@hvgotcodesThank you for the response is there any sort of example that you know of that I can look at to study. I have never really tried doing this and would be great if I had some sort of base to start with.Thanks Again,Kelly
kelly
I have found this page which I think will give me a good starting point if I have any specific questions or get stuck somewhere then I will post another question. Here is the page I am referring to http://www.electrictoolbox.com/load-content-jquery-ajax/ if you have any others that you feel may help please do not hesitate to reply.Kelly
kelly
@kelly -- good luck.
hvgotcodes
I found the answer I was looking for on this page and thought I would post it for anyone else who may be wanting to do the same thing. Here is the page I am referring to. http://www.brightcherry.co.uk/scribbles/2009/02/26/jquery-auto-refresh-div-every-x-seconds/Kelly
kelly