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 9095357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:34:42+00:00 2026-06-16T23:34:42+00:00

I’m trying to pass a value to a Url.Action like so $(‘._select_change’).change(function(n) { var

  • 0

I’m trying to pass a value to a Url.Action like so

     $('._select_change').change(function(n)
     {
         var param = n.target.value;

         $.get('@Url.Action("List", new { someid = param } )', function (data) {
             $('#changeArea').replaceWith(data);
         });

     });

if i set someid = ‘123’, then the value carries through fine. However when I replace with someid = param – i get a compiler error “CS0103: The name ‘param’ does not exist in the current context” …

how should i structure this method call?

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-06-16T23:34:43+00:00Added an answer on June 16, 2026 at 11:34 pm

    how should i structure this method call?

    Like this:

    $('._select_change').change(function() {
        var param = $(this).val();
        $.get('@Url.Action("List")', { someid: param }, function (data) {
             $('#changeArea').replaceWith(data);
        });
    });
    

    Notice how I am using the second argument of the $.get() method to pass query string arguments to the AJAX call from the client.

    This would pass the selected value of a dropdown to the List controller action taking a someid action argument:

    public ActionResult List(string someid) 
    {
        ...
    }
    

    So what you will see in the Net tab of your javascript debugging tool is the following AJAX request being sent to the server:

    GET /somecontroller/List?someid=123
    

    There’s one thing though that you should be careful with if you use this $.get() method. GET requests are usually cached by browsers. This means that if you send many requests to the same url like /list?someid=123 the browser could cache the result and only the first request will ever reach the server. But what if you want to server fresh data every time and you want to hit the server for each request. The recommended solution in this case is to use the $.ajax() method instead which allows you to disable the cache:

    $('._select_change').change(function() {
        var param = $(this).val();
        $.ajax({
            url: '@Url.Action("List")',
            data: { someid: param },
            cache: false,
            success: function (data) { 
                $('#changeArea').replaceWith(data);
            }
        });
    });
    

    This will append a random query string parameter on each request to ensure that the result is not cached by the client browser.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.