On 4 avr, 08:44, "mikewilson" <[EMAIL PROTECTED]> wrote:
> If I give Ajax.Updater a first arg like{ success: 'replies', failure:
> 'errors'}, how do I return an error from a php script so the message
> goes in 'errors' rather than 'replies'?

The function doesn't anticipate any response type from the server. You
should read the API to know what onFailure and onError convers (and
what are their role in the request). As long as success is executed,
you should handle your server response from there. This is so, because
return values and error handling should not be limited to a standard
since there can be as many different implementations as there are
types of responses.

You may consider using a general purpose response handler for your
requests if you plan on using the same implementation in your return
value (which is a good idea by the way). For instance, try looking at
Ajax.Responders to register a global callback function.

In any case, if you only want to handle one kind of response the way
you do, it is clear that onFailure, and onError are not appropriate to
warn the user about that kind of failure, as they should be used only
if there is a problem with the returned value itself (i.e. a malformed
XML document for instance) or if the script/server is unavailable for
the moment. If onSuccess is called, it means that the request has
successfully been executed, regardless of if the script encountered an
error or not.

If you are using JSON, you may consider having a value 'errorCode' and
'errorMsg' (or similar) in your response. If errorCode == 0, then the
request was successful. If you are using XML, you may consider using a
tag such as <error> to enclose information about exceptions, etc.

The benefit of having a general error handler is that errors may be
catch and process in a cohesive way. Which means that if you change
the way you want to handle errors, you will not find yourself
refactoring all your code to compensate for the inconsistencies.

If you are using XML, you may consider Rico (at http://www.openrico.org/)
which allows you to register XML tags to elements (that will be
automatically updated) or objects (that will be called with the node
as parameter). [...]

Good luck.

-yanick


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to