Export pdf file using ajax in MVC C #

Multi tool use
Export pdf file using ajax in MVC C #
I would like to know how to export an excel file using ajax, I have tried in the following way, but it does not work:
$("#ajax_loader").css("display", "");
var formato = "PDF";
//window.location.href = url;
//$("#ajax_loader").hide();
var fd = new FormData();
fd.append("format", formato);
fd.append("nombreObra", $('#nombre_obra').val());
$.ajax({
type: "POST",
url: '<%= Url.Action("Export", "Obras")%>',
data: fd,
DataType: 'json',
contentType: false,
processData: false,
success: function (data) {
$("#ajax_loader").hide();
}
});
});
If anyone has any ideas, I would greatly appreciate it. Greetings.
javascript
'Content-disposition', 'attachment; filename=some-filename.csv'
'Content-Type': 'text/csv'
In title you mentioned Export pdf fille and in description export an excel file. So what you want to achieve? And also post your controller code.
– mmushtaq
Jul 3 at 5:07
export PDF file
– Carmen Cisterna Chamblas
Jul 3 at 5:18
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
You'd need a
javascript
way to convert your data to csv stackoverflow.com/questions/14964035/… OR set the headers on the server'Content-disposition', 'attachment; filename=some-filename.csv'
&'Content-Type': 'text/csv'
– Lex
Jul 3 at 4:53