How can I change the href of an anchor after it has been clicked?
<p>I have a page that pulls in data via AJAX. As well as this I have a link to download said data as a CSV file.</p>

<p>The problem I have is that upon I need to pass some parameters along with the click event so that the server can return the correct CSV file.</p>

<p>Without any processing the link looks like this:</p>

<pre><code>&lt;a href="/manager/TargetResults.csv" class="black"&gt;Download Target Reports&lt;/a&gt;
</code></pre>

<p>This then fires off an ASP.NET MVC Controller action that returns the CSV. What I want to do though is pass two parameters along in the query string. Initially I thought that I could intercept the click event and add data to the query string like so:</p>

<pre><code>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 + "&amp;newOutlets=" + newOutlets;
anchor.attr('href', link);
</code></pre>

<p>It would seem that changing the href at this stage will not update the link in time and the URL will be as it was when it hits the server?</p>

<p>Is it possible to change a URL after it has been clicked or do I need to look at another method?</p>

<p>Thanks</p>
