views:

26

answers:

0

I have a page where:

  • At a regular interval (5s), an Ajax request is sent to the server to refresh the page.
  • The page has links (<a href="...">) allowing the user to download documents.

And this is what happens:

  1. In some cases, the user clicks the link to download the file while the Ajax request is in progress.
  2. The link points to a file that gets downloaded by the browser, but apparently Safari assumes that a new page is loaded and stops the Ajax request to load the file.
  3. The file is successfully downloaded by Safari, but since the Ajax query was stopped (the connection was closed), the Ajax call fails.

To handle this situation, I could just in this case add code to consider that if the Ajax query fails in this way, it is OK. But is there a way to get Safari to load a file without interrupting Ajax requests in progress, at least until it determines that what it gets back from the server is a web page that will replace the current page?