I am trying to download pdf file through JavaScript / jQuery. My code is:
function ShouldGeneratePdf() {
            $.ajax({
                url: "/Report/EmployeeReport",
                type: 'POST',
                data: {
                    EmployeeId: $('#EmployeeId').val()
                },
                cache: false,
                async: false,
                success: function (data) {
                    debugger;
                    //Convert the Byte Data to BLOB object.
                    var blob = new Blob([data], { type: "application/pdf" });
                    //Check the Browser type and download the File.
                    var isIE = false || !!document.documentMode;
                    if (isIE) {
                        window.navigator.msSaveBlob(blob, fileName);
                    } else {
                        var url = window.URL || window.webkitURL;
                        link = url.createObjectURL(blob);
                        var a = $("<a />");
                        a.attr("download", "testFile.pdf");
                        a.attr("href", link);
                        $("body").append(a);
                        a[0].click();
                        $("body").remove(a);
                    }
                },
                error: function () {
                    debugger;
                }
            });
        }
Above method does download the pdf but the downloaded file is empty. Any idea what i am doing wrong ? Any help would be much appreciated.
PS: PDF file also includes images.
 
    