Indeed, my proposed fix was incorrect -- an alert does NOT need to be
passed into the function as a callback (it's always globally available)
and since the parameter for the alert is response text, that's A-OK. If
you want to insert that response into the page (and not just 'alert' it),
you WOULD need to create a callback function which made reference to the
page element 'target' (thus serving as a closure).
One thing about XHR -- you have all four HTTP verbs at your disposal: GET,
POST, PUT, DELETE and so you may wish to use one of the non-safe (i.e.
state-changing) methods for your XHR call (probably POST in the case of
adding a tag) to make things more RESTful. XHR is actually a very good
way to "hijack" links (which are otherwise going to simply use 'GET')
which will perform state-changing operations. Then when your application
starts exposing web services, you'll be that much more aligned with
RESTful principles (I'm convinced that's v. important, although plenty of
successful services expose unsafe GETs). Just a thought...
On Thu, 29 Nov 2007, Eric Lease Morgan wrote:
On Nov 29, 2007, at 9:21 AM, Eric Lease Morgan wrote:
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 to it. Instead, I separated my form input/
validation routine from the httpRequest functionality and the problem
disappeared. Don't ask my why. I don't know. This makes for better
since I am really only starting out in this regard I think I need to
get my hands dirtier before I lean on someone else's code.
Finally, for posterity's sake, I have included my resulting code in
an attachment to this message. I don't know whether or not the list
will accept attachments.
Eric Lease Morgan
University Libraries of Notre Dame