File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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

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.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

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

[Asking smart questions] [About Bear] [Books by Bear]
Alexei White

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="" target="_blank" rel="nofollow"></a><br />Enterprise Ajax Book <a href="" target="_blank" rel="nofollow"></a><br />f. 604.985.9287
I agree. Here's the link:
subject: Ajax request within some time should return response
It's not a secret anymore!