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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:05:42+00:00 2026-06-01T22:05:42+00:00

I am trying to pass two values to the following controller action using jQuery

  • 0

I am trying to pass two values to the following controller action using jQuery

[HttpPost]
        public JsonResult Cancel(Guid Id, string cancelReason)
        {
            //do something
        }

.js:

    CancelProgram = function (Id) {
//this is basically the value from a select tag placed on the form            
var reason = $("#CancelReasons").val();
            alert(reason);

            Origin.ajax({
                url: '/ZYX/Cancel?Id=' + Id,
                type: 'POST',
                dataType: 'json',
                data: { cancelReason: reason },
                success: function (data) {
                    alert('success!');
                }
            });
        };
    });

The value of cancelReason in the action method is always null. Any pointers on why this is not working?

  • 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-01T22:05:44+00:00Added an answer on June 1, 2026 at 10:05 pm

    There must be something wrong with another part of your code. I would start by sending a normal AJAX request by hardcoding the values and ensuring that they are properly sent:

    $.ajax({
        url: '/ZYX/Cancel',
        type: 'POST',
        data: { 
            id: '24fe0c97-c227-4312-91fc-6e651df8b64f', 
            cancelReason: 'some reason' 
        },
        success: function (data) {
            alert('success!');
        }
    });
    

    Once you ensure that this simple example works start making it more dynamic by using variables. This way you will be able to narrow down and find the origin of your problem. Also I would very strongly recommend you using a javascript debugging tool such as FireBug. It allows you to see in the Console whether you have javascript errors as well as many other useful information such as the exact requests/responses being sent.

    In the case of a successful AJAX request here’s what you should see in the Network Tab of FireBug:

    Accept:             */*
    Accept-Encoding:    gzip, deflate
    Accept-Language:    en-us,en;q=0.5
    Connection:         keep-alive
    Content-Length:     64
    Content-Type:       application/x-www-form-urlencoded; charset=UTF-8
    User-Agent:         Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) Gecko/20100101 Firefox/10.0
    X-Requested-With:   XMLHttpRequest
    
    id=24fe0c97-c227-4312-91fc-6e651df8b64f&cancelReason=some+reason
    

    Notice how both the id and the cancelReason parameters are sent using application/x-www-form-urlencoded.

    You should really learn to debug those kind of problems and the way to debug them is by using the proper tools.

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

Sidebar

Related Questions

I'm trying to pass two values on Button_Click Event public MyClass() { Int64 po
I am using this code. Trying to pass form values from one internal page
I'm trying to pass two values to a function, so that i can check
I'm trying to code a way to pass the values from two spinners into
im trying to pass two parameters to a function, i being an int value
I am trying to make an app that will pass data between two servers
In my GWT project, I'm trying to get it so two DialogBoxes can pass
Trying to pass in a user supplied string which has a path to the
Trying to pass a string argument to a function, which will then be used
I am trying to pass parameters from Visual Studio using VB.net to a Crystal

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.