Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

best practices for AJAX framework implementation [closed]

Tags:

java

ajax

What are the best-practices in implementation of AJAX framework and handling 'special' cases as:

  • Session timeout on AJAX call (redirect to login page, error, ignore...)
  • Server exceptions in AJAX request
  • Server session state in multiple following AJAX calls
  • Browser reload of page where AJAX calls has been made
  • Browser back to page where AJAX calls has been made
  • Delayed AJAX requests
  • ...

Any articles, books, notices, ... will be helpful. Either general AJAX or specialized for some server side implemetations.

(My case is java, component based state-full UI framework, AJAH's like AJAX (asynchronous java-script and HTML)

NOTE: I've been googling for a while and all I've found are articles about how AJAX is cool or how to implement it with help of some framework. Nothing about how to write such framework, what are general problems when doing it, etc...

like image 245
Juraj Avatar asked Feb 05 '09 12:02

Juraj


1 Answers

I do not know a website or a book with all theses answers but perhaps have some clue.

I already had the session problem and here's what I thought :

  • I think the best way to handle the session timeout is to display a message to user, several minutes before the timeout, saying that the session will soon expire which means he will lost what he did. The message should contain an ajax link which will send a request to server in order to clear the session timeout and close that message.
  • In the case of the user is not in front of it's screen and the session timeout has expired, you may display close the previous message and display another one saying that the session has expired, and propose to reload the page by saving user's input data if any (or at least, say him that he will lost what he eventually just type).

In oder to handle the browser "back" or "reload" action when you used Ajax, I think you should take a look about reallysimplehistory project which allows you to set a state about a piece of URL.

Also, I read the book Ajax Patterns and Best Practices which gives me some piece of advice about specific Ajax problems. Perhaps that will help you too.

like image 118
paulgreg Avatar answered Oct 27 '22 16:10

paulgreg