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

  • Home
  • SEARCH
  • 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 7963611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:38:50+00:00 2026-06-04T05:38:50+00:00

looking for a bit of Ajax help here… I have quite a complex view

  • 0

looking for a bit of Ajax help here…

I have quite a complex view which is built on quite a complex ViewModel.

On the page I have 3 columns where each column represents a full journey which then breaks down to show the individual flights.

Each flight is represented by a box containing details (start and end locations, departure time, arrival time, operator etc)
The box also contains a dropdown list of all other possible flights that could be taken from this location (e.g. you might want to hang around the airport for an additional 6 hours, so you could choose a later flight!)

Anyway, by changing one possible flight, I’m going to have to update the entire column, because taking a later flight will mean subsequent flights might not be possible anymore.

Which leads to my question – is it possible for me to pass a complex viewmodel back to the controller via jQuery? Can it be done using partial views that are nested inside foreach loops?
All I want to do is update the column via ajax, but I can’t see how to pass the viewmodel back. I’m trying to avoid doing a full page reload because it will be quite a cumbersome search so ajax updates would be ideal

Here is some cut-down code for the process:

Code for View (index.cshtml) – the jQuery is found here within the main view

@foreach (var item in Model)
{
    <div id="column-@groupCount">
        @Html.Partial("_JourneyColumnPartial", item)
    </div>
}

<script type="text/javascript">
    $(".flightItem").change(function (event) {
        alert(event.target.id);
        var cSelected = $(this).val();
        alert(cSelected);
        $.ajax({
            url: "/Search/GetChangeInfo",
            contentType: "application/json",
            type: "POST",
            dataType: "json",
            data: ({ cID: cSelected }),
            success: function (display) {
            }
        });
    });
</script>

Code for first partial view (_JourneyColumnPartial.cshtml)

<div class="routeContainer">
    @Html.Partial("_ColumnItemPartial", Model)
</div>  

Code for child partial view (_ColumnItemPartial.cshtml)

@{
    int journeyNumber = 1;
}
@foreach (var journey in Model.SelectedJourneys)
{
    List<JourneyDetails> list = Model.Journeys.Where(j => j.JourneyDateAndTimeID != journey && j.DepartureID == hub.DepartureID && j.ArrivalID == hub.ArrivalID).OrderBy(j => j.JourneyDateAndTime).ToList();
    <div class="box">
        <div class="journeytimes">
            <b>Depart</b> @hub.DepartureDate<br />
            <b>Arrive</b> @hub.ArrivalDate<br />
        </div>
        <div class="boxcontrols">
            <select class="flightItem" id="flightItem_@{<text>@Model.ColumnNumber</text><text>_</text><text>@journeyNumber</text>}">
                @foreach (var flight in list)
                {
                    <option value="@flight.JourneyID">@flight.ProviderName - @flight.JourneyDateAndTime</option>                                                    
                }                                            
            </select>

        </div>
        <!-- end of box -->
    </div>
    journeyNumber++;    
    <!-- end of box wrap -->
}

I know I’ve not included details about the ViewModel, but it is quite complex and includes generic lists of other classes so it is quite large. The trigger for the ajax/jQuery is the change event of the dropdown list.

If this makes absolutely no sense, feel free to say and I’ll try and clarify what I’m looking for!

Thanks

  • 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-04T05:38:51+00:00Added an answer on June 4, 2026 at 5:38 am

    It is possible by sending your data as json in your jquery call.

    You can achieve this by simply create a javascript object like your ViewModel, and convert that javascript object to string by Json.Stringify method and set the string value to the data in the ajax call.

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

Sidebar

Related Questions

I have a page which uses a fair bit of ajax to load its
I'm looking at a complex bit of JavaScript, which is doing all sorts of
I have a php mysql application. On a detail view page, I am looking
I have a report model looking a bit like this: class Report(models.Model): date =
Looking for a bit of advice on where to take a current webapp which
Been looking around a bit and I can't seem to find any help on
I'm looking for a bit of help ironing out a bug in a search
I've been looking into EJS and JavaScriptMVC. I see quite a bit of value
I've got a page on my site that requests quite a bit of content
Not a great title but I'm looking more for some guidance, have searched quite

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.