Request a Proposal
Facebook Instagram Twitter Youtube Google+


Refreshing an element at a set time interval using jQuery and a sprinkle of Ajax

Posted at Jan 13, 2009 7:02:56 AM by Ronald Busky | Share

Now lets say that you a web page that has a big Block of "something" and inside this "something" you would like to have some information change at a set time interval. Well with Jquery, some PHP and a sprinkle of Ajax, you can get this done quick fast and in a hurry.

The first thing you will need, is obviously the latest jQuery Javascript library file. and you will also need this light JQuery Timers Plugin. Now lets set up:

I am going to assume that you know a little about JQuery and say that you already know how to call from inside the "Head" tag. The following is basically the "meat and potatoes" if you will of what is going on.

Let's Break it down.

1. First we say "Hey you with the class name of refreshMe, I am going to do something to you every 10 seconds. (SideNote * 1000 = 1 second; So 5,000 = 5 seconds).

2. Now we use JQuery's built in Ajax functions to call the URL of the page we want to bring in and have it refresh the element with the class name of refreshMe with the information from this page that called. Follow? Good.

Now since for some deranged reason, I can't get the code highlighter to work correctly Click here to see the page in action. You will be able to view source from there.

Or download it now.

Tags: Web Development

2018 Digital Marketing Guide | THAT Agency