How long will the browser wait after an ajax request?

前端 未结 4 1423
醉话见心
醉话见心 2020-12-07 22:41

How long can the browser wait before an error is shown before server answers for request? Can this time be unlimited?

4条回答
  •  忘掉有多难
    2020-12-07 23:03

    Can you explain a bit more about what you're trying to achieve - do you have a long running process on a server, do you want to change the settings on just a local machine or are you after a way to manage it for large numbers of users?

    How long the browser will wait depends on a number of factors e.g. where the timeout occurs - is it at the TCP level, the server or the local browser?

    If you've got a long running process on a server and you want to update a webpage afterwards the typical way to handle it is to run the long process asynchronously and notify the client when it's complete e.g. have an ajax call that polls the server, or use HTTP 1.1 and serve out a notification stream to the client.

    In either case it's still possible for the connection to be closed so the client will still need the ability to re-open it.

提交回复
热议问题