3

I would like some recommendations on the best way to handle errors in AJAX-powered applications. Specifically, the methods used to log the errors and what do you do to address them.

An obvious priority is that I don't want any user input lost. I was hoping to come up with some sort of fallback mechanism so that if an AJAX post fails, a natural form POST can be attempted using the same data. Any suggestions?

2
  • What makes you think that the same server error would not occur with a regular POST? Commented Mar 10, 2009 at 18:32
  • Obviously, it could be an error on the client-side! Commented Mar 10, 2009 at 19:32

2 Answers 2

1

Use the command pattern: User actions could be considered commands, such as "user entered this text" or "user moved this thing here." Each command could be an object stored in a FIFO queue. As the more commands are executed, subsequent Ajax calls post them to the server. If an Ajax post fails, the commands simply build up in the queue until the client is able to post them.

Sign up to request clarification or add additional context in comments.

Comments

0

So your question is really "How do I make sure there aren't any client-side errors?"

You need to test it extensively.

A post is a post no matter what, if one fails the other one is likely to also.

If you want an idea, you could start keeping a client side javascript log and if an error occurs you could post to a general error handling page that stores the log for safe keeping.

But then what if that errors? You could go on and on, but really: just test it thoroughly and you'll end up with minimal client side errors.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.