DannyR
DannyR

Reputation: 69

Ajax xmlhttprequest timeout

I am creating a small web app.

In one of the webpage in the app, part of the page is update using ajax. Ajax will retrieve the data from a java servlet on the server.

I am new to ajax (and javascript) and I don't understand some of the in's and out's of it.

Do I need to use xmlhttprequest.timeout in case the server take too long to send the response? I understand that some browsers don't support this, so is it unrelaible?

Does ajax consume data while waiting for the response from the server? I am asking this in case the server takes too long to send the response and the user is using a mobile device with data allowance limits?

I would appreciate any help on this

Edit: I am using tomcat on the backend server. How can I tell tomcat to send a 408 (server timeout), if the request/response is taking to long to process? I understand that I cannot do this in server.XML as connection timeout is only if the server has not received the request or am I wrong?

Upvotes: 0

Views: 406

Answers (1)

Quentin
Quentin

Reputation: 943099

Do I need to use xmlhttprequest.timeout in case the server take too long to send the response?

No. The browser/network stack's default timeout is usually sufficient.

Does ajax consume data while waiting for the response from the server?

It is just an HTTP request and response. It takes no more bandwidth than any other request. If no data is being transferred because the server is taking time to respond, then no data is being transferred.

Upvotes: 1

Related Questions