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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:58:44+00:00 2026-06-12T06:58:44+00:00

Im trying to pass these json object to the code behind var obj =

  • 0

Im trying to pass these json object to the code behind

var obj = {
        Name: '1',
        Starting: '3',

        Timeline: [
        {
            StartTime: '111',
            GoesFor: '111'

        }
        ,
        {
            StartTime: '112',
            GoesFor: '112'

        }

    ]
    };

of course the next step is to stringify the object

var data = JSON.stringify(obj);

after that I use a jquery ajax call to pass the value to code behind

$.ajax({
            url: 'default.aspx/test',
            type: 'POST',
            contentType: 'application/json',
            data: data,
            success: function(result) {
                $('#result').html(result.d);
            }
        });

the point is im getting error form the jquery library

POST http://localhost:63050/default.aspx/test 500 (Internal Server Error)

the problem is solved when I remove the obj variable, and put it into the JSON.stringfy method, like this

var data = JSON.stringify({
            obj: {
                Name: '1',
                Starting: '3',

                Timeline: [
                {
                    StartTime: '111',
                    GoesFor: '111'

                }
                ,
                {
                    StartTime: '112',
                    GoesFor: '112'

                }
                ]
            }
        });

Is there anyway to passing the entire object variable into the json.stringify function, instead of declare and initializing within the function?

In case you guys wanted to know, my code behind looks something like this

public class MyModel
{
    public string Name { get; set; }
    public string Starting { get; set; }
    public testing2[] Timeline { get; set; }
}

public class testing2
{
    public string StartTime { get; set; }
    public string GoesFor { get; set; }
}

[WebMethod]
    public static string Test(MyModel obj)
    {
        return "Hello from test" + obj.Name + obj.Starting + obj.Timeline[0].StartTime + obj.Timeline[1].StartTime;
    }
  • 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-12T06:58:45+00:00Added an answer on June 12, 2026 at 6:58 am

    No, because in your example you are passing in an object, so you need to put the JSON data into an object for it be parsed as an object. Otherwise what you are passing is just an array of variables.

    Basically, you could correct the problem like this:

        $.ajax({
            url: 'default.aspx/test',
            type: 'POST',
            contentType: 'application/json',
            data: { obj: data },
            success: function(result) {
                $('#result').html(result.d);
            }
        });
    

    That way you can use your original stringify.

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

Sidebar

Related Questions

I am trying to pass a simple JSON object to a controller using MVC3
I am getting some weird results while trying to pass a complex JSON object
I trying to create a json object and pass that object to template.render(JSONObj) ,
I'm trying to create a JSON object on form submit to pass to Perl.
I am trying to pass the fullcalendar events to my controller via Json, however
I have a JSON object that I need to pass from the server to
I am trying to pass JSON data from the client browser to an ASP.NET
I am trying to pass array of files object to spring MVC controller. But
Could anyone assist me with how I can pass one JSON object as a
I am trying to pass these variables from 3 hidden fields to the data

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.