Deprecated: Assigning the return value of new by reference is deprecated in /home/desandie/www/blog/wp-includes/cache.php on line 36

Deprecated: Assigning the return value of new by reference is deprecated in /home/desandie/www/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/desandie/www/blog/wp-includes/theme.php on line 507

Warning: Cannot modify header information - headers already sent by (output started at /home/desandie/www/blog/wp-includes/cache.php:36) in /home/desandie/www/blog/wp-content/plugins/BAStats/BAStats_logger.php on line 99
China Musings » I am AJAX Ready

China Musings

Writings and Ramblings (A/V) from Guangzhou, China

I am AJAX Ready

Filed under: Work Related, Web Development — Adeh at 1:47 am on Friday, December 30, 2005

For the backstreet project, I wrote a WP plugin that allows the user to control what shows up on the front page. One of those items was the main graphic, the big pic that sort of sets the tone for the whole front page. The reasoning behind it was so that they could use that space to promote big acts. Of course, they have not used it even once!

Anyway, I have recycled that plugin now for CCIC, and tonight, I decided to update it a little. The idea is that the users can upload as many pictures as they like, as long as they are the right size, and the front page will rotate through the pictures randomly each tome the page reloads.

Since I did backstreet, I have been using Gmail, and I really like how it is able to grab content in the background without me doing anything. So I got to thinking… what if you didn’t have to reload to see a new photo on the front page. How can we use AJAX to reload the images in the bacground, say on a timer.

Well, I have been following the XMLHttpRequest movement very closely, but I had not actually written any code. I decided this was the place to start. And you know what, it was rather anti-climactic. 5 minutes. It literally took 5 minutes to turn the front page into an automatic Javascript based slideshow that works like a charm. Now granted, I already had the infrastructure in place. So the images are already uploaded, there is already a function that returns a random image name. All I had to do was hook that function to a GET level parameter and copy some code from this excellent tutorial. (It is rare when a 1 page tutorial leads you to a point where you can do something useful, but here I am)

To be fair, it really isn’t AJAX, since I am not returning any XML, just a plain string. However, I find this extremely useful, and I think I am going to be using it in other places as well.

So go ahead and check it out http://cameraitacina.net.cn

1 Comment »

330

Comment by John

January 27, 2006 @ 4:59 pm

I too was surprised at just how easy AJAX is, and how fast you can knock together a little script to do something fancy. It all seems so obvious now, and I’m itching to sprinkle the goodness in places that don’t need it…

Hope you have a good Chinese New Year in GZ!

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> <img src="">