2

I am redirecting user using window.location.href to a page that forces a file download using the following headers:

Content-Description: File Transfer
Content-Disposition: attachment; filename="foo"

As a result, user is not taken to the page, though asked if he wishes to proceed downloading the file.

How do I tell when the response from the server is received?

The user flow that I am trying to achieve:

  1. Display loader.
  2. "redirect" the user (with window.location.href).
  3. Hide loader when response is received.
4

1 回答 1

2
  • 从您的客户端代码中,还将生成的 ID 传递给服务器,要求它为您设置一个 cookie 为该值。
  • 您的服务器端代码应将 cookie 与下载的文件(在 HTTP 标头中)一起传回。
  • 然后,您可以在重定向后轮询 javascript 中的 cookie,以查看服务器何时响应成功连接。
于 2013-02-24T14:22:57.880 回答