I'm trying to implement file download functionality thru ajax call in MVC. After calling of controller method i always have a "parseerror", can somebody explain me why?
my ajax:
tab.on("click", ".FileDownload", function (e) { //$('#uploadStatus').html("ok"); var tr = $(this).closest("tr"); var id = tr.data("id"); $.ajax({ type: "POST", url: "/File/FileDownload", //contentType: false, //processData: false, //dataType: "json", data: { fileId: id }, success: function (data) { $('#uploadStatus').html("ok"); }, error: function (err) { alert(err.statusText); } }); }); and controller:
[HttpPost] public FileResult FileDownload(int? fileId) { FileDBEntities db = new FileDBEntities(); tblFile file = db.tblFiles.ToList().Find(p => p.id == fileId.Value); return File(file.Data, file.ContentType, file.Name); } with simple download link in razor it works, but not with ajax. What am I doing wrong here?