HTML Button's jQuery function is having trouble with MVC FileResult
- by Aaron Salazar
I intended for this function to call my MVC action method that returns a CSV report.
$(function() {
$('#exportButton').click(function() {
$.get('/curReport/GetCSVReport');
});
});
If I make a button like the code below then, when it is clicked, I'm given the "Open with/Save File" window.
<input type="button" value="Export" onClick="location.href='CurReport/GetCSVReport'">
However, when I change my button to use my jQuery function then, although GetCSVReport() is called I'm not given the "Open with/Save File" window.
Here is my GetCSVReport()
public FileResult GetCSVReport()
{
...
return fileResult;
}
How can I get my jQuery function to work like the onClick?
Thank you,
Aaron