The errback callback is only invoked upon HTTP header status codes I
assume.
So the question is, what is a good model to communicate application
level messages and errors?
E.g. I'm doing a POST to insert a database record. Assume this fails
on the and I want to have my client-side to handle this gracefully.
Same would go for server side validation of other sorts. What's a
good way to send this meta-data back which is easy to use by the client?
Right now, I'm just returning html snippets. Not doing anything with
JSON or XML yet.
In one case, I'm returning multiple snippets separated by a 'well-
known' string. The client 'splits' the responseText and put's each
snippet part where it belongs. I suppose, one could add a simple
protocol header ahead of the snippets and interpret that upon success
to handle such situations.
But I'm always looking for good and reusable solutions, especially
within MochiKit. So if anyone with more experience than me can make
some suggestions here, I'd really appreciate it.
Thanks,
Juergen
You can use an error status code and you'll get the error object in
the errback. You can still get at the XMLHttpRequest from that error
object.
http://mochikit.com/doc/html/MochiKit/Async.html#fn-xmlhttprequesterror
-bob