I have a page that retrieves data through AJAX. In addition, I have a link to download the specified data as a CSV file.
The problem is that I need to pass some parameters along with the click event so that the server can return the correct CSV file.
Without processing, the link looks like this:
<a href="/manager/TargetResults.csv" class="black">Download Target Reports</a>
Then the ASP.NET MVC Controller action is launched, which returns the CSV. What I want to do is pass two parameters in the query string. Initially, I thought I could intercept the click event and add the data to the query string like this:
var holder = $('.hidden-information').first();
var newOutlets = $('input[name="newoutlets"]', holder).val();
var queryDate = $('input[name="enddate"]', holder).val();
var anchor = $(this);
var link = anchor.attr('href');
link = link + "?endDate=" + queryDate + "&newOutlets=" + newOutlets;
anchor.attr('href', link);
It seems that changing the href at this point will not update the link in time, and the URL will be what it was when it hits the server?
URL , ?