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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:14:57+00:00 2026-05-26T05:14:57+00:00

I’m having issues passing my list object to my controller – using an ajax

  • 0

I’m having issues passing my list object to my controller – using an ajax post.

in the view I have this:

        try {
        var id = schedule.value;
        var data2 = @Html.Raw(Json.Encode(Model.SavedScheduleList));
        var url = '@Url.Action("SetActiveSchedule", "Frame")';
        $.post(url, { savedScheduleList: data2, signScheduleDataId: id }, function (data) { 
        });
    }
    catch (err) 
    {
        alert(err);
    }

My Controller looks like this:

    [HttpPost]
    public ActionResult SetActiveSchedule(List<SelectListItem> savedScheduleList, int signScheduleDataId)
    {
        try
        {               
            return Json(null);
        }
        catch (Exception ex)
        {
            throw;
        }
    }

So when my Action is executed, my savedScheduleList contains a list object with 7 objects (which is the correct number of items I’m sending through. However each item seems to be “blank”. ie, of the SelectListItem class, these are the property values for each item: Selected = false, Text = null, Value = null.

The Model class (which has been strongly typed to this view) is:

    public class ScheduleModel
{

    private SignSchedule activeSignSchedule = new SignSchedule();
    private List<SelectListItem> savedSignScheduleList = new List<SelectListItem>();

    public int SignDataId { get; set; }
    public ScheduleFrameList ListFrames { get; set; }
    public DateTime Start { get; set; }
    public LogMessage LogMessage { get; set; }
    public bool CommsLogVisible { get; set; }
    public SignSchedule SignScheduleToMakeActive { get; set; }
    public int ActiveSignScheduleId { get; set; }
    //public List<SignSchedule> SavedSignScheduleList { get { return savedSignScheduleList; } }
    public List<SelectListItem> SavedScheduleList { get { return savedSignScheduleList; } }
}

Examining data2 before the post, shows the correct data in Json format and examining the Request property within the Action I can see the correct values in the Form.AllKeys property as well as the Params property but it doesn’t seem to correctly resolve it back to my parameter object of the Controller Action.

Is it possible what I’m trying to do?

Thanks

EDIT
Here’s a string representation of data2 variable:

var data2 = [{"Selected":false,"Text":"9","Value":"2589"},false,"Text":"afsdfs","Value":"2585"},false,"Text":"sdfas","Value":"2588"}....]

I’m just showing 3 items here but there is in fact 7 as expected.

  • 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-26T05:14:57+00:00Added an answer on May 26, 2026 at 5:14 am

    The easiest way to send complex objects and lists is to use a JSON request, like this:

    var id = schedule.value;
    var data2 = @Html.Raw(Json.Encode(Model.SavedScheduleList));
    $.ajax({
        url: url,
        type: 'POST',
        contentType: 'application/json; charset=utf-8',
        data: JSON.stringify({ savedScheduleList: data2, signScheduleDataId: id }),
        traditional: true,
        success: function(result) {
            // TODO: do something with the results
        }
    });
    

    Note that the JSON.stringify function is natively built into modern browsers. But if you need to support legacy browsers you could include the json2.js script into your page.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have thousands of HTML files to process using Groovy/Java and I need to
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites 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.