defunkt / jquery-pjax

pushState + ajax = pjax
https://pjax.herokuapp.com
MIT License
16.74k stars 1.97k forks source link

If download a file, pjax will happen. #698

Open fukeric opened 6 years ago

fukeric commented 6 years ago

If download a file, pjax will happen.

  // Prefer X-PJAX-URL header if it was set, otherwise fallback to
  // using the original requested url.
  var serverUrl = xhr.getResponseHeader('X-PJAX-URL')
  obj.url = serverUrl ? stripInternalParams(parseURL(serverUrl)) : options.requestUrl

+  if (!xhr.getResponseHeader('Content-Type').match(/^text\/html/i))
+    return obj;

So I solved it in the same way as above.

anandiamy commented 5 years ago

if the file is in the form of an image, it doesn't download it, but displays it

how to be downloaded?