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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:12:53+00:00 2026-06-14T07:12:53+00:00

I am not looking to use the ajax jQuery method. I would like to

  • 0

I am not looking to use the ajax jQuery method. I would like to use the .load() method for a div. Here’s what my javascript method looks like:

function PartialViewLoadArray(aName, aValue, aGuid, aName2, aValue2, aGuid2) {

    modelArray = [];

    modelArray.push({ Name: aName, Value: aValue, Guid: aGuid });
    modelArray.push({ Name: aName2, Value: aValue2, Guid: aGuid2 });

    $('#examplediv').load(
        '/Example/PartialByModelArray/',
        { ModelArray: modelArray },
        function () {
            alert('the load has completed!');
        }
    );
}

Here is the action on the controller:

public PartialViewResult PartialByModelArray(ExamplePartialArrayModel aModel)
{
    return PartialView("_ExamplePartialByArray", aModel);
}

My array model:

public class ExamplePartialArrayModel
{
    public ExamplePartialModel[] ModelArray { get; set; }
}

The model contained in the above model:

public class ExamplePartialModel
{
    private string _Name;
    private int? _Value;
    private string _Guid;

    public string Name
    {
        get { return this._Name; }
        set { this._Name = value; }
    }

    public int? Value
    {
        get { return this._Value; }
        set { this._Value = value; }
    }

    public string Guid
    {
        get { return this._Guid; }
        set { this._Guid = value; }
    }
}

I know I can get this div to load the content if I render the partial view manually using the context and a stringwriter, etc, but it seems to me as though I should be able to get this load() statement to work. Why isn’t MVC picking this data up? What is EXTREMELY odd is that when I set a breakpoint on the first line of my action it’s showing me two items in the array–but all their properties are null. How can it determine the amount of items in the array but not bind their values? What is going on? I am mystified.

  • 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-14T07:12:55+00:00Added an answer on June 14, 2026 at 7:12 am

    The problem is that the data is being posted as form data and jquery does this in a format that the default model binder can’t understand. In my test I used fiddler to see that the data came through in this format:

    ModelArray[0][Name]  : name1
    ModelArray[0][Value] : value1
    ModelArray[0][Guid]  : guid1
    ModelArray[1][Name]  : name2
    ModelArray[1][Value] : value2
    ModelArray[1][Guid]  : guid2
    

    The easiest way to fix this is to post the data in json format:

    function PartialViewLoadArray(aName, aValue, aGuid, aName2, aValue2, aGuid2) {
        var modelArray = [];
    
        modelArray.push({ Name: aName, Value: aValue, Guid: aGuid });
        modelArray.push({ Name: aName2, Value: aValue2, Guid: aGuid2 });
    
        $.ajax({
            type: 'POST',
            url: '/home/PartialByModelArray/',
            contentType: 'application/json',
            data: { ModelArray: modelArray },
            success: function (response) {
                $('#examplediv').replaceWith(response);
            }
        });
    }
    

    Note that this code used the json2 library to encode the json data and your controller action should be marked with the [HttpPost] attribute.

    I’m not sure why you don’t want to use the ajax method, but you could also look at finding a way to encode the form data into a more mvc friendly format or write a custom model binder, but that all seems like a lot more effort. This post explains the issue a bit more and might give you some ideas.

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

Sidebar

Related Questions

I am looking for a javascript(better if based on jquery) Ajax image viewer with
I'm looking to use NVelocity in my ASP.NET MVC application, not as a view
I'm looking for some advice on whether or not I should use a separate
I'm not looking to keyword spam here, and this question is in the least
I am not looking for the answer here but just how to find the
There are already questions about the Perl+AJAX, like here , here or here and
I need to use the $.ajax() call within jQuery to post a little bit
I'm currently using Prototype, but I'd like to rewrite this function to jQuery: function
What would be a good way to attempt to load the hosted jQuery at
Iam looking for jquery php image upload exactly given in http://valums.com/ajax-upload/ . i tried

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.