I want to send an \"ajax download request\" when I click on a button, so I tried in this way:
javascript:
var xhr = new XMLHttpRequest(); xhr.open(\
You actually don't need ajax at all for this. If you just set "download.php" as the href on the button, or, if it's not a link use:
window.location = 'download.php';
The browser should recognise the binary download and not load the actual page but just serve the file as a download.