I need to do a Javascript method that calls an ashx (generic handler) that returns an array of bytes (a file). This file can be XML, TXT or PDF. Until then I solved the problem, but when the file does not exist, I'm redirected to another page, but I just want to display an alert with the error message.
function GetFile(idAction, chave, fileType) {
window.downloadfile = function (e) {
window.location = "MyHandler.ashx?parameter1="
+ idAction + "¶meter2=" + fileType + "¶meter3=" + chave;
}
downloadfile();
}