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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:48:05+00:00 2026-05-25T19:48:05+00:00

For submitting the form data to the server from the AJAX call to bind

  • 0

For submitting the form data to the server from the AJAX call to bind Telerik MVC grid, we can set e.data in OnDataBinding event to a anonymous JavaScript object

<script type="text/javascript">
function Grid_onDataBinding(e) {
     var categoryValue = "Beverages";
     var priceValue = 3.14;

     // pass additional values by setting the "data" field of the event argument
     e.data = { 
        // the key ("category") specifies the variable name of the action method which will contain the specified value
        category: categoryValue,
        price: priceValue
     };
}
</script>

To facilitate the model binding for Boolean, ASP.NET MVC generates checkboxes along with a hidden text field with the same name

<input name="myCheckBox" class="check-box" id="myCheckBox" type="checkbox" CHECKED="checked" value="true"/>
<input name="myCheckBox" type="hidden" value="false"/>

and when these are submitted the data submitted is

myCheckBox=true&MyCheckBox=false – when the checkbox is checked

myCheckBox=false – when the checkbox is not checked

For pages where there is no checkbox, the post data can be easily obtained by

e.data = form.serializeObject()

where serializeObject creates that object by looping thru all the form fields. How to construct that object in case of forms when there are checkboxes as described above? Basically how can a name-value pair list be represented in the object form when the names are allowed to be duplicate?

e.data = { 
    textBox1: "some value1",
    myCheckBox: true //,
    //myCheckBox: false // ???
};

The implementation of serializeObject creates an array for such form elements and those are submitted as myCheckBox[]=true&myCheckBox[]=false which breaks the model binding on the server side.

  • 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-25T19:48:05+00:00Added an answer on May 25, 2026 at 7:48 pm

    You can select specific form subelements to serialize, rather than just serializing the entire form. This allows you to filter out the ones you don’t want:

    $('form input:not([type=hidden])').serializeObject();
    

    Edit: Per @amit_g’s comment, you want the checkbox when it’s checked or the hidden element when it’s not. This requires a more complex filter than the :not selector:

    $('form input')
        .filter(function() {
            if ($(this).attr('type') == 'hidden') {
                // filter out those with checked checkboxes
                var name = $(this).attr('name');
                return !$('form input[type=checkbox][name=' + name +']')
                    .prop('checked');
            } else {
                // include all other input
                return true;
            }
        })
        .serializeObject();
    

    See the working jsFiddle here: http://jsfiddle.net/nrabinowitz/nzmg7/4/

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

Sidebar

Related Questions

When submitting one form from view, how can i also read or have controller
I am trying to stop my form from submitting yet I never can get
My application involves using submitting data (the request) from a form into an SQL
Hey guys, I am trying to run a proccess by submitting an AJAX form:
I have a form I am submitting using jQuery's ajaxSubmit function from the Forms
I have a form I am submitting via AJAX (using prototype and the built-in
My PHP file doing 2 operations: 1. Submits data from form into db table,
I am submitting my array from jQuery Datatables for server side processing, in the
I'm sending AJAX form from page in http scheme to https url (the domain,
I am submitting from a form to another php page which is supposed to

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.