Good
point. I had stayed away from this thread, but I was wondering why this
alternative wasn't considered:
Add an
HTML comment to the responseText (the content), e.g.,
<!-- *ServerStatus: condition-here -->
(It
could even be the first line)
Any
condition (string, numeric or both) could tell the client-side a message without
mucking with the Http conditions, which are tricky enough as they
are.
Maybe
the content is XML? Add an XML element that describes the
condition... I suppose it depends heavily on the type of data
stream... perhaps modifying the http in (some) situations is
correct.
BTW: I've observed that when onFailure is called, onComplete is
called immediately after. I was surprised, and it changes what
processing is expected in each handler.
Sam
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Martinez, Andrew Sent: Thursday, June 29, 2006 8:54 AM To: rails-spinoffs@lists.rubyonrails.org Subject: RE: [Rails-spinoffs] Ajax.Updater I don’t mean to hijack the thread. I might
possibly be misunderstanding Il Neofita’s intentions with positive/negative
feedback. Just for clarifications here are the two meanings I can
see: 1) The Ajax
operation was being used to send data to the server, the server would return a
true/false value based upon that data that was computed server
side. 2) The Ajax
operation was being attempted and the positive/negative feedback is being used
to determine if the server is present, not present, or if the request failed due
to some other network related problem. Now, if we are in situation #1, is it
really a good idea to use HTTP response failure headers, thus triggering the
onFailure event, to signify an invalid computational value? Won’t we then lose
the ability to tell if the serer is simply not present? I would imagine it would
be better for the server to send response text back to the client that signifies
a failure. Reserving error responses for situation 2, when we really need to
know that the Ajax request isn’t being computed as a failure, it just isn’t
reaching the server properly. Unless situation #2 is what Il Neofita’s
intention the entire time, then I am sorry to waste time. There is of course another situation, where
I am completely misunderstanding the importance of
onFailure….. -Andrew Martinez -----Original
Message----- From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Il
Neofita Sent: Thursday, June 29, 2006 4:08
AM To:
rails-spinoffs@lists.rubyonrails.org Subject: Re: [Rails-spinoffs]
Ajax.Updater Thank you, now everything is
clear. On 6/29/06, Thomas Fuchs
<[EMAIL PROTECTED]> wrote: A HTTP server returns a HTTP status code
with every answer. The Ajax.Request object knows about this, and will execute the onSuccess
function only if a non-error status code was returned (normally "200 OK"). You can also fine-tune
this by using the various methods described on the Wiki page Martin
mentioned. Note that your server-side web development
framework should allow you to set these status codes. What do you use on the
server? For more info about this, see
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html . -Thomas Am 28.06.2006 um 18:41 schrieb Il
Neofita: I cannot understand something
with declaring this object new Ajax.Request
I will request the page /my/url however, on the server side, how should
look the files? I canno tunderstand how can I give a positive o negative
feedback Thank you and sorry for these basic
question On 6/28/06, Martin Ström
<[EMAIL PROTECTED] > wrote: Something like this should do it:
new Ajax.Request("/my/url", {
asynchronous:
true, onSuccess: function(r)
{ $("myDiv").innerHTML = "updated!
new contents " + r.responseText; }, onFailure: function(r)
{
alert("failed!") } }) See the docs (
http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request ) for more
info Ciao Martin On 6/28/06, Il Neofita <
[EMAIL PROTECTED]> wrote: Hi Andrew, I am not so good in Java, can you send me a
basic example. Thank you On 6/28/06, Martinez, Andrew <
[EMAIL PROTECTED]> wrote: Don't use Ajax.updater. Use the regular
Ajax object and then pass in your own onSuccess function handler/function
pointer/functor. The handler/pointer/functor will receive the response test in a
HTTP request object and you can evaluate it there. -Andrew Martinez -----Original
Message----- From:
[EMAIL PROTECTED] [mailto:
[EMAIL PROTECTED] On Behalf Of Il
Neofita Sent: Wednesday, June 28, 2006 10:49
AM To:
rails-spinoffs@lists.rubyonrails.org Subject: [Rails-spinoffs]
Ajax.Updater Hi, someone can help me, I am ot able to find
the way how to user Ajax.updater to test if the request give some positive or
negative result. I am able only to return the result inside
a div. An example is appreciated.
|
_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs