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're using IE, which means you need to issue the open() before
adding the onreadystatechange handler.
Otherwise, open will trigger a call to your handler, and IE's
implementation won't have reset the readyState to 0.
In either event, you should double-check that the status of the
request is 200
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
To point out why the use of a Javascript framework is important, let me
put your code into jQuery (http://jquery.com)
$.get('index.cgi', {cmd:'add_tag', username:'username'}, function(html) {
// do whatever you want here
})
PrototypeJS has a similar, easy to use construct. In the end, using
9:22 AM
To: CODE4LIB@listserv.nd.edu
Subject: [CODE4LIB] httpRequest javascript grrr
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
jQuery++
I like to do things from scratch, but have never regretted moving to
jQuery. Whatever time it takes you to check it out will be paid back
a thousand times, at least.
Keith
On 11/29/07, Ewout Van Troostenberghe [EMAIL PROTECTED] wrote:
To point out why the use of a Javascript
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
On Nov 29, 2007, at 9:21 AM, Eric Lease Morgan wrote:
Why doesn't my httpRequest Javascript function return unless I add
an alert? Grrr.
I have resolved my problem, but I'm not exactly sure how.
First of all, my httpRequest (XMLHttpRequest) code was just fine. I
made no significant changes