Live Data Retrieval

Relates to DOM Scripting

I have been experimenting at every opportunity with XmlHttpRequest ever since I first saw it implemented over at Bitflux in the now reknowned Live Search. It has been integral to a number of supplemental enhancements to my PHP CMS. I decided to test drive the items grabber utility for Live Data Retrieval a bit further by crossing it over to this weblog, and this feature can now be seen in the archives menu.

There is nothing fancy in the implementation. Just a bit of DOM manipulation to send a request to the server and retrieve a list of the titles of each entry posted for a month. It is a convenience tool that allows the user to browse the entire archive without leaving the entry page. The data is cached on the server and after the initial request it is also cached in a Javascript object for the duration of the page session.

The Javascript source is available here. The code develops a number of techniques I have discussed in recent months. One line of code that may look a little odd to the untrained eye is the following:


(function (elem) {    
  var btn, listener;
  btn = document.createElement('button');
  elem.insertBefore(btn, elem.firstChild);
  listener = new XListener(btn);
}).Iterate(listitems);

This is actually just an anonymous function that could just as easily be written:


function addButtons(elem) {
  var btn, listener;
  btn = document.createElement('button');
  elem.insertBefore(btn, elem.firstChild);
  listener = new XListener(btn);
}
addButtons.Iterate(listitems);

But the interesting code is the Iterate method which is a custom method of the Function prototype:


Function.prototype.Iterate = function(collection) {
  for (var i = 0, elem; elem = collection.item(i++); ) {
    this(elem);	
  }  
}

Essentially a utility function to handle the iteration of a routine over a collection of DOM nodes.

While this XmlHttpRequest implementation works perfectly well in IE6, I have temporarily prevented this due to Exploder's mis-interpretation of the float model causing some incongruous placement issues. I have yet to test it in the latest Opera betas.

Posted on Sunday, Oct 17, 2004 at 21:46:26.

Comments on Live Data Retrieval (2)

α comment

Hi

Please can any one help me to manage a stick up footer on the website for IE 5.0 +. Its designed in CSS or JavaScript or Both.

As you can see 1 on http://www.bmw.co.uk . Any kind of help is highly appriciated.

thanks

Imran Hashmi http://www.visionstudio.co.uk

Posted by imran
Thursday, Nov 03, 2005 at 23:51:04

β comment

Thanks so very much for taking your time to create this very useful and informative site. I Wish good luck in development! http://cheapvaliumonline.info valium

Posted by Kixaqas
Thursday, Apr 06, 2006 at 13:23:18

Breadcrumbs Trail

[ Home ] -> TW Blog -> Oct 04 -> Live Data Retrieval
Site Map

The Severn Solutions website achieves the following standards:

[ XHTML 1.0 ] [ CSS 2 ] [ WAI AA ] [ Bobby AA ]

Page compiled in 0.010 seconds