HTML Button's jQuery function is having trouble with MVC FileResult

Posted by Aaron Salazar on Stack Overflow See other posts from Stack Overflow or by Aaron Salazar
Published on 2010-03-30T15:39:35Z Indexed on 2010/03/30 15:43 UTC
Read the original article Hit count: 475

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript