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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:36:52+00:00 2026-05-31T04:36:52+00:00

I am getting some weird results while trying to pass a complex JSON object

  • 0

I am getting some weird results while trying to pass a complex JSON object to an action in MVC 3.

The Locations are populated on the action parameter model, but the name and location are not.

If I do ko.toJS(testViewModel), then the name and location are there, but the locations are blank???

I am using knockout.js:

var testViewModel = {
        Name: ko.observable("Joe Bob"),
        Locations: ko.observableArray([
            { ID: 1, Name: "Salem, OR" },
            { ID: 2, Name: "Big Bear Lake, CA" },
            { ID: 3, Name: "Big Bear City, CA" }
        ]),
        Position: ko.observable("Manager")
    }

Sending it via jQuery ajax:

$.ajax({
            url: "/ClaimsAuthority/Home/TestIt",
            type: "POST",
            data: ko.toJSON(testViewModel),
            success: function (data, status, xhr) {
                //ko.applyBindings(data);
            }
        });

MVC Action:

<HttpPost()>
        Public Function TestIt(model As TestModel) As ActionResult
            Return Json(model)
        End Function

Models:

Public Class TestModel 
    Public Property ID As Integer
    Public Property Name As String
    Public Property Locations As ICollection(Of LocationModel)
    Public Property Position As String  
End Class

Public Class LocationModel
    Public Property ID As Integer
    Public Property Name As String
    Public ReadOnly Property DisplayText As String
        Get
            Return String.Format("({0}) {1}", ID, Name)
        End Get
    End Property
End Class
  • 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-31T04:36:54+00:00Added an answer on May 31, 2026 at 4:36 am

    Try setting the content type to application/json in your AJAX request:

    $.ajax({
        url: '/ClaimsAuthority/Home/TestIt',
        type: 'POST',
        contentType: 'application/json',
        data: ko.toJSON(testViewModel),
        success: function (data, status, xhr) {
            //ko.applyBindings(data);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting some weird results while parsing some XML in JavaScript. I have the
I am trying to compare 2 strings but getting weird results. On some computers,
I'm getting some weird behavior from IE when trying to change a session variable
I'm getting some weird results, so I need to just check myself... SELECT *
I am getting some weird numbers returned from the characterAtIndex method for Object-C in
Hi i am trying to use pchart library but i am getting some weird
I'm getting some weird behaviour recompiling some applications in 2009 that used widestrings at
I'm getting some weird black spots with a custom map page (via the Google
I'm working on a school project and I'm getting some weird errors from Xcode.
I'm getting some confusing results around myCustom.ashx handler. If i visit the handler via

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.