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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:33:31+00:00 2026-06-09T23:33:31+00:00

I want to receive json object from view to controller using $.ajax method but

  • 0

I want to receive json object from view to controller using $.ajax method but i dont know why the receive object in controller shows null data.

here is my code.

$("#Save").click(function (e) {

       $.ajax({ url: "Home/Save",
        type: "POST",
        datatype:'json',                
        data: ({movies:movies})
      });
});

where movies is javascript array which contains

    ({
    Name:"DDLJ",Stars:"SRK",Director:"Yashraj",Year:"2012"
    }, {Name:"K3G",Stars:"SRK",Director:"Karan",Year:"2010"}
)

and my controller code is:

public string Save (List<MovieDB> movies)
        {
         return "";
        }

where MovieDB is my model class which have the properties

public class MoviesDB   
    {
        //public int MoviesID { get; set; }
        public string Name { get; set; }
        public string Stars { get; set; }
        public string Director { get; set; }
        public DateTime Year { get; set; }
    }

Please suggest me any better way to receive json data from view to controller.

Actully I try to send javascript array object from view to controller action method in which my array code is

<script type="text/javascript">
    var cnt = 1;
        var cnt2 = 1;
        var i;
        var movies = [];

    movies.push({ Name: $("#txtMovieName").val(), Stars: $("#txtStarCasts").val(), Director: $("#txtDirector").val(), Year: $("#txtYear").val(), Index: cnt++ });

                    $("#modelTable").empty();

                    $("#modelTemplate").tmpl(movies).appendTo($("#modelTable"));

                    $("#txtMovieName").val("");
                    $("#txtStarCasts").val("");
                    $("#txtDirector").val("");
                    $("#txtYear").val("");
                    $("#txtMovieName").focus();
                    e.preventDefault();
            });

  $("#Save").click(function (e) {

            //var jm = $.toJSON(movies);
            $.ajax({ url: "Home/Save",
                type: "POST",

                data: ({movies:movies})
                // contentType: 'application/json; charset=utf-8'
             });
        });

    </script>

Now I want to send that movies javascript array object to Save() Action method of controller using any way like json or other please suggest me something…

  • 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-09T23:33:32+00:00Added an answer on June 9, 2026 at 11:33 pm
     List<xyztype> lstid = new JavaScriptSerializer().Deserialize<List<xyztype>>(IDlist);
    

    is working for me

    here xyztype is my collection class type and IDlist is my json objectstring from view to controller action method

    by using javascriptserializer().deserializer<> we can convert json string to our custom or system datatype object

    for example :

      List<string> lstid = new JavaScriptSerializer().Deserialize<List<string>>(IDlist);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create JSON object from JSON data receive from server as A
I want to receive json from php to ajax and want to access the
I want to receive a JSON object using Ruby. I've written this: require 'sinatra'
We want all of our AJAX calls in our web app to receive JSON-encoded
I receive a JSON response in an Ajax request from the server. This way
My problem is I receive an JSON text from say, twitter. Then I want
i developed client server program using c++,so i want to receive more than 500kb
I want to send and receive commands like dir and so on but i
I have following json data which I want to pass it to server using
Case: I receive a JSON string from third-party server, containing a list of objects.

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.