On click of a link, I am trying to download a pdf document. For simplicity, the code shown below is downloading an image. I have referred the example as seen in http://jsfiddle.net/Qjvb3/. Inside the click event handler of the link, I am trying to do the same thing and it works.
   jQuery(document.body).on('click', '.downLoadLink', function (event) {
   }
But when I try to do the same thing inside an ajax call, the image is not getting downloaded.
   ds.downloadDxRecordForm = function (fileName,downloadAnchorElement,pdfFile) {
        return Q.when($.ajax({
            type: "GET",
            url: config.nccsysWebApiEndpoint + 'DxRecordForm/DownloadDxRecordForm',
            data: {
                fileName: fileName
            },
            contentType:'application/pdf',
            beforeSend: function (jqXhr) {
                ds.setXhrRequestHeader(jqXhr);
                jqXhr.setRequestHeader('Accept', 'application/pdf');
            }
        }).then(function (data) {
           //I am placing the jsfiddle code here
           //$(downloadAnchorElement).attr("href",.....).attr("download","..")
        }).fail(function (promise) {
            return ds.ajaxFailed(promise,
                {
                });
        }));
    };
};
To this ajax call I am passing the anchor element and then trying to set the href and download attributes when the ajax call is completed. In the console window I see that attributes are getting added to the anchor element but somehow the image is not getting downloaded.
