Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3455324
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:36:02+00:00 2026-05-18T09:36:02+00:00

I have a page that pulls in data via AJAX. As well as this

  • 0

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.

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.

Without any processing the link looks like this:

<a href="/manager/TargetResults.csv" class="black">Download Target Reports</a>

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:

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 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?

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

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:36:03+00:00Added an answer on May 18, 2026 at 9:36 am

    You could redirect the window yourself, like this:

    var holder = $('.hidden-information').first();                                   
    var newOutlets = $('input[name="newoutlets"]', holder).val();
    var queryDate = $('input[name="enddate"]', holder).val();
    window.location.href = this.href + "?endDate=" + queryDate + "&newOutlets=" + newOutlets;
    return false; //prevent default going-to-href behavior
    

    Or, whatever is updating those hidden fields, update the link then instead of when it’s clicked, for example:

    $("#someField").change(function() {
      var holder = $('.hidden-information').first();                                   
      var newOutlets = $('input[name="newoutlets"]', holder).val();
      var queryDate = $('input[name="enddate"]', holder).val();                              
      $("a.black").attr("href", function() {
        return "/manager/TargetResults.csv" + "?endDate=" + queryDate + "&newOutlets=" + newOutlets;
      });
    });
    

    The main difference is this still allows normal click behavior to work, ctrl+click, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this javascript that pulls some data via an ajax request the method
I have a php page that pulls data from a mysql database based on
I have a page that pulls 2-3 chunks of data from sql. these chunks
I have a log in page that pulls information from a data base, I
I have a page that pulls together aggregate data from two different tables. I
I would like to have filtering page that performs ajax requests to asynchronously update
chevrolet/?brand=chevrolet&state=<?php echo $_GET['state'];?> chevrolet/ has an index.php file that pulls the data for the
I'm using Joomla 1.5. I have created a custom component that pulls data out
Okay, my dilemma is this. I have an admin page that I use to
The goal is to have a singleton data controller class called FetchData.h/.m that pulls

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.