Don't leave out the Yahoo YUI library as something to consider. Whats nice is that you don't have to load the entire library as one big huge js file - you can pick and choose what libraries you want to include in your page minimizing the javascript filesize. If you want to have one little js widget on you page - the browser doesn't need to download and process a 150kb prototype js file. Andrew > -----Original Message----- > From: Code for Libraries [mailto:[log in to unmask]] On Behalf Of > Jonathan Rochkind > Sent: Thursday, November 29, 2007 10:24 AM > To: [log in to unmask] > Subject: Re: [CODE4LIB] httpRequest javascript.... grrr > > These days I think jquery seems more generally popular than prototype. > But both are options. I definitely would use one or the other, instead > of doing it myself from scratch. They take care of a lot of weird > cross-browser-compatibility stuff, among other conveniences. > > Jonathan > > Jesse Prabawa wrote: > > Hi Eric, > > > > Have you considered using a Javascript Library to handle these > details? I > > would recommend that you refactor your code to use one so that you > can > > concentrate on what you actually want to do instead. This way you can > also > > avoid having browser incompatabilities that are already solved if you > use a > > Javascript Library. Try checking out Prototype at > > http://www.prototypejs.org/ > > > > Best regards, > > > > Jesse > > > > On Nov 29, 2007 10:21 PM, Eric Lease Morgan <[log in to unmask]> wrote: > > > > > >> Why doesn't my httpRequest Javascript function return unless I add > an > >> alert? Grrr. > >> > >> I am writing my first AJAX-y function called add_tag. This is how it > >> is suppose to work: > >> > >> 1. define a username > >> 2. create an httpRequest object > >> 3. define what it is suppose to happen when it gets a response > >> 4. open a connection to the server > >> 5. send the request > >> > >> When the response it is complete is simply echos the username. I > know > >> the remote CGI script works because the following URL works > correctly: > >> > >> http://mylibrary.library.nd.edu/demos/tagging/? > >> cmd=add_tag&username=fkilgour > >> > >> My Javascript is below, and it works IF I retain the "alert > >> ( 'Grrr!' )" line. Once I take the alert out of the picture I get a > >> Javascript error "xmldoc has no properties". Here's my code: > >> > >> > >> function add_tag() { > >> > >> // define username > >> var username = 'fkilgour'; > >> > >> // create an httpRequest > >> var httpRequest; > >> if ( window.XMLHttpRequest ) { httpRequest = new > XMLHttpRequest(); } > >> else if ( window.ActiveXObject ) { httpRequest = new > ActiveXObject > >> ( "Microsoft.XMLHTTP" ); } > >> > >> // give the httpRequest some characteristics and send it off > >> httpRequest.onreadystatechange = function() { > >> > >> if ( httpRequest.readyState == 4 ) { > >> > >> var xmldoc = httpRequest.responseXML; > >> var root_node = xmldoc.getElementsByTagName( 'root' ).item( 0 > ); > >> alert ( root_node.firstChild.data ); > >> > >> } > >> > >> }; > >> > >> httpRequest.open( 'GET', './index.cgi?cmd=add_tag&username=' + > >> username, true ); > >> httpRequest.send( '' ); > >> alert ( 'Grrr!' ); > >> > >> } > >> > >> > >> What am I doing wrong? Why do I seem to need a pause at the end of > my > >> add_tag function? I know the anonymous function -- function() -- is > >> getting executed because I can insert other httpRequest.readyState > >> checks into the function and they return. Grrr. > >> > >> -- > >> Eric Lease Morgan > >> University Libraries of Notre Dame > >> > >> (574) 631-8604 > >> > >> > > > > > > -- > Jonathan Rochkind > Digital Services Software Engineer > The Sheridan Libraries > Johns Hopkins University > 410.516.8886 > rochkind (at) jhu.edu