File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Ajax request within some time should return response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajax request within some time should return response" Watch "Ajax request within some time should return response" New topic
Author

Ajax request within some time should return response

sridhar lakka
Ranch Hand

Joined: Jan 02, 2007
Posts: 109
Hi All,
Thanks a lot in advance.
In our application we are using struts and ajax.
I have a jsp page from which i am passing one ajax request to get some data.In some special case like network failure or system hang after passing this ajax request if this kind of problem occured then user may not know what is happened.To prevent this kind of misunderstanding. After passing ajax request if response is not returned within some time frame say after ten minutes an alert should some saying there is some problem.
Please guide me how to do thi, if possible with some example code.

Regards,
Sree
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

Investigate the use of window.setTimeout() and the abort() method of XMLHttpRequest.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Alexei White
author
Greenhorn

Joined: Jul 20, 2007
Posts: 14
I think Bear is on the right track.

I would use a couple things. I'd definately keep my finder on the 'abort()' method incase its taking TOO long, and I would also use a window.setTimeout() to trigger this action..

I would also want to alert the user that the request is going to take a while and use either an activity indicator, a progress bar, or both. You can also use a progress bar to track the progress of a server-side activity. Chapter 9 gives a detailed example of this.

By the way, here are some great activity indicators: Activity Indicators
[ July 26, 2007: Message edited by: Alexei White ]

Alexei White<br />Nitobi Software<br />-------------------<br /><a href="http://www.nitobi.com" target="_blank" rel="nofollow">www.nitobi.com</a><br />Enterprise Ajax Book <a href="http://www.enterpriseajax.com" target="_blank" rel="nofollow">http://www.enterpriseajax.com</a><br />f. 604.985.9287
 
wood burning stoves
 
subject: Ajax request within some time should return response
 
Similar Threads
Migrating Application - From Struts with AJAX to JSF with AJAX
Ajax and servlet problem
how to log ajax request in tomcat httpmonitor
Problem with Synchronous Ajax call
Export to xls file - Download file using AJAX