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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:15:09+00:00 2026-06-13T19:15:09+00:00

What I’m trying to do is to pass JSON object to a WebAPI ajax

  • 0

What I’m trying to do is to pass JSON object to a WebAPI ajax call and mapped to a strongly typed object on the server side. String values are being posted perfectly however when it comes to boolean values, they are not being passed at all. Below is my code:

 var gsGasolineField = $('.gsGasoline').val();
 blData = { Gasoline: gsGasolineField  };

 var json = JSON.stringify(blData);
 $.ajax({
         type: "POST",
         url: url,
         data: json,
         contentType: "application/json",
         dataType: "json",
         statusCode: {
                      201 /*Created"*/: function (data) {
                            $("#BusinessLayerDialog").dialog("close");
                            ClearForm("#BusinessLayerForm");
                        },
                        400: /*Bad request - validation error*/ function (data) {
                            $("#BusinessLayerForm").validate().form();

                        },
                        500: function (data) {
                            alert('err');
                        }
                    },
         beforeSend: setHeader
                });

Gasoline property is of type boolean on the server side.

EDIT:

As mentioned above, Gasoline is boolean and being MVC my HTML markup is as follows

<div style="float: left">@Html.CheckBoxFor(x => x.GasStation.Gasoline, new { @class = "gsGasoline" })</div>

So I’m just taking the values of this checkbox and passing it to the JSON object

EDIT

Also tried to to send it true directly

blData = { Gasoline: true  }; 

Still false 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-06-13T19:15:10+00:00Added an answer on June 13, 2026 at 7:15 pm

    The problem turned out to be due to the inheritance aspect of my server side architecture. All properties in the parent class are being deserialized correctly and everything in the child class remains untouched. Nothing was related to the type passed to the JSON.Stringify function.

    Thank you all for your help.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
i got an object with contents of html markup in it, for example: string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
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
I want to count how many characters a certain string has in PHP, but
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
Specifically, suppose I start with the string string =hello \'i am \' me And

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.