jquery - unable to download dynamically created file -
i've created custom action result in mvc application, generate csv file according configuration user provides.
however. problem have if create download link this:
<a id="lnkdownload" href="<%= url.action("downloadfile", "download", new { id = model.id, userid = model.userid, startdate = "30/05/2010", enddate = "30/05/2005"}) %>">download</a>
it works fine. thing i've introduced 2 date time controllers on page, user can set start , end date. therefore i'm adding in dates controller url this:
$('#lnkdownload').click(function() { var startdate = $('#tbextratestartdate').val(); var enddate = $('#tbextrateenddate').val(); var link = $('#lnkdownload').attr('href') + "&startdate=" + startdate + "&enddate=" + enddate; $.get(link, function() { }); return false; });
this gives me problem "download prompt" not appear @ all. i've tried figure out why, haven't found solution.
how can solve this?
the reason download not working because attaching click handler anchor , send ajax request $.get
action instead of normal request won't work.
you can keep click handler don't send ajax request, update href
of anchor.
Comments
Post a Comment