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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:31:28+00:00 2026-05-30T01:31:28+00:00

Im trying to send a array to my method with $.post() but Im kinda

  • 0

Im trying to send a array to my method with $.post() but Im kinda lost how to go about this.

I am getting the values of the checkboxes thats outside my form and pass them into my method.

I tried to use .serializeArray() & .serialize() but get the error that

list.serializeArray is not a function

I i just send in the array i get null value.

HTML

<form....><input type="submit" value="submit" id="click_post" /></form>

<div id="container">
        <input type="checkbox" value="2,3" name="checkbox" />
        <input type="checkbox" value="4,5" name="checkbox" />
        <input type="checkbox" value="6,7" name="checkbox" />
</div>

JQUERY

$('#click_post').click(function () {
                var list = new Array();
                $('#container input[type="checkbox"]').each(function () {
                    list.push($(this).val());
                });

                var $form = $(this).closest('form');
                $.post($form.attr('action'), { value: list }, function (data) {
                    alert('test');
                });
            });

METHOD

public ActionResult PassArray(string[] value){//doing some logic here}
  • 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-30T01:31:29+00:00Added an answer on May 30, 2026 at 1:31 am


    $(‘#click_post’).click(function () {
    var $form = $(this).closest(‘form’);
    $.post($form.attr(‘action’), $form.serialize(), function (data) {
    alert(‘test’);
    });
    });

    and also change the name of your action parameter to checkbox (because that’s what you used as name for the checkboxes in the form):

    public ActionResult PassArray(string[] checkbox) {
        ...    
    }
    


    UPDATE:

    or if you wanted to send only the values of the checkboxes and not any other form input elements you might need to use the traditional mode:

    $('#click_post').click(function () {
        var list = new Array();
        $('#container input[type="checkbox"]').each(function () {
            list.push($(this).val());
        });
    
        var $form = $(this).closest('form');
        $.ajax({
            url: $form.attr('action'),
            type: 'POST',
            traditional: true,
            data: { value: list },
            success: function(result) {
                alert('test');
            }
        });
    });
    

    or:

    $('#click_post').click(function () {
        var list = new Array();
        $('#container input[type="checkbox"]').each(function () {
            list.push($(this).val());
        });
    
        var $form = $(this).closest('form');
        $.post($form.attr('action'), $.param({ value: list }, true), function(result) {
            alert('test');
        });
    });
    

    and then:

    public ActionResult PassArray(string[] value) {
        ...    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to send an array to a PHP script via POST method. First
I am trying to send data with POST, but the result is array(0) when
I am trying to send the database Array by using the method below: OracleConnection
I am trying to send an e-mail using php script but i am getting
I am trying to send an array of about 50 elements to a WCF
I have the following where I'm trying to send list/array to MVC controller method:
I'm trying to use jQuery's $getJSON to send an array of 'ids'. Here's what
I'm trying to convert a struct to a char array to send over the
I'm trying to send an email in Java but when I read the body
I am trying to send an email from a site I am building, but

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.