Using Ajax to download files is not considered a good idea. Instead, use window.location = or document.location .
'window.location' Has the following characteristics -
Redirection can depend on any condition, for example -
$success = 1 if ($success) { window.location.href = 'http://example.com'; }
A variable named "success" is assigned a value of 1. When this condition is met, window.location will be used.
When run, the user will be redirected to the website "http:" //example.com'
The above is the detailed content of Download file via AJAX call in PHP. For more information, please follow other related articles on the PHP Chinese website!