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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:28:46+00:00 2026-06-04T20:28:46+00:00

I have a stringified JSON object that appears properly in an alert, appears properly

  • 0

I have a stringified JSON object that appears properly in an alert, appears properly in the post section in the browser debugger, but in the controller it appears as null. I’m not sure how it is losing the information.

Here is the JS code:

 var assessmentStatus = [];

            $("select.assessmentSelect").each(function () {
                assessmentStatus.push({
                    assessmentname: $(this).attr("id"),
                    assessmentstatus: $(this).val()
                });


            });
alert(JSON.stringify(assessmentStatus));


            $.ajax({
                url: '@Url.Action("testAS")',
                type: "POST",
                contentType: 'application/json',
                data: JSON.stringify({
                    AS: assessmentStatus,
                    AS2: assessmentStatus

                })

            });

this is what is appearing in the alert:

[{"assessmentname":"testassessment","assessmentstatus":"Design"},{"assessmentname":"DepressionUpload","assessmentstatus":"Design"}]

this is what is appearing in the post:

[Object { assessmentname="testassessment", assessmentstatus="Design"}, Object { assessmentname="DepressionUpload", assessmentstatus="Design"}]

my controller looks like this:

public ActionResult testAS (string[] AS, string AS2)

string[] AS returns [0]null  [1]null
string AS2 just returns null.

Why is it not getting stringified when being sent to the controller?

  • 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-04T20:28:47+00:00Added an answer on June 4, 2026 at 8:28 pm

    You seem to be attempting to pass an array of complex objects with 2 properties:

    assessmentStatus.push({
        assessmentname: $(this).attr("id"),
        assessmentstatus: $(this).val()
    });
    

    to a simple array of strings: string[] as. This is obviously not gonna work.

    So start by defining a view model:

    public class AssessmentViewModel
    {
        public string Name { get; set; }
        public string Status { get; set; }
    }
    

    then adapt your controller action:

    public ActionResult TestAS(AssessmentViewModel[] assessments)
    {
        ...
    }
    

    and finally your javascript:

    var assessments = [];
    $('select.assessmentSelect').each(function () {
        assessments.push({
            name: $(this).attr("id"),
            status: $(this).val()
        });
    });
    $.ajax({
        url: '@Url.Action("testAS")',
        type: "POST",
        contentType: 'application/json',
        data: JSON.stringify({ assessments: assessments })
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to bind a JSON stringified object to a model and few
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
Have a matrix report now that has Position, Hours and Wages for a location
have not tested on windows. but in ubuntu when u disconnect from the network,
I have javascript object which consists of complex array of structures with nested structures
Here is a simple scenario: I have a blog post with comments attach to
Have converted devise new session from erb to Haml but doens't work, this is
Have searched the database but need to specifically sum(of hours flown or days off)in
Have a bunch of WCF REST services hosted on Azure that access a SQL
I have the following php object(??? new to this). It is being sent through

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.