• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Ajax Error Handling

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've seen documents and chapters in books discussing error handling when using ajax techniques. However, these often have to do with dealing with server issues like session time outs, 503's, etc. I haven't found very much good documentation on dealing with things like form validation errors or general bad data "please correct this" type of error handling.

For example, last night I was trying to hone up on my ajax skills and was making a login form that exists on every web page of an app. The user would use this form to log into the app, but instead of a page refresh, I was just popping some User specific data into the login form DIV container, replacing the login for all together. This was easy.

But I soon ran into complexities when I started validating the login form and the submitted user data. Where I first was using Ajax.Updater I had to switch to Ajax.Request and pass back messages in XML of success or failures. Parsed that in Javascript and deal with it accordingly. Needless to say, something simple became a bit complex quickly.

Does anyone have any links to reference material about such situations/issues?

Thanks.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's lots to be said on this, but unfortunately today is one of those "crazy days' so I need to be briefer than I'd like to be.

But, remember that you are not limited to merely what you can return in the response body. You can also set the reponse status code and make use of Prototype's onFailure handlers.

For example, when an Ajax request detects that the user's session has timed out, I set the status code to an error code which triggers the onFailure handler (which then causes the redirect to the login page).
[ March 28, 2007: Message edited by: Bear Bibeault ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
There's lots to be said on this, but unfortunately today is one of those "crazy days' so I need to be briefer than I'd like to be.

But, remember that you are not limited to merely what you can return in the response body. You can also set the reponse status code and make use of Prototype's onFailure handlers.

For example, when an Ajax request detects that the user's session has timed out, I set the status code to an error code which triggers the onFailure handler (which then causes the redirect to the login page).

[ March 28, 2007: Message edited by: Bear Bibeault ]



Ok, see, I wondered if I were able to do that, set the response status code. I'll check into that. Thanks Bear.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic