What is the best way of showing progress on an Ajax call?

前端 未结 12 1080
遥遥无期
遥遥无期 2020-11-28 05:17

I have an Ajax call that updates 5,000 records in a database so this takes a lot of time. I have an Ajax \"Loading image\" showing that something is happening, but I am loo

12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 05:35

    You could update the response buffer with a progress, flushing your response buffer periodically from the server.

    But you may have trouble reading a request before it's complete via xhttpr. You might be able to make your request via an iframe, and have that load in progress via 'http streaming'.

    But even that can be sketchy. HTTP is not the meant to transfer things piecemeal/fragmented. Like others point out, it would be best to make a separate subsequent calls to get the status of the operation.

提交回复
热议问题