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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:39:31+00:00 2026-06-10T04:39:31+00:00

I’m working on a project that uses both jQuery Mobile and an MVC3 backend.

  • 0

I’m working on a project that uses both jQuery Mobile and an MVC3 backend. On one of the pages the user is asked to select options from a couple of dropdown menus or leave them as the defaults. The page takes the selected options and throws them into an object which it then sends to the server to load the next page of data. I have tried two different ways of doing it and both ways give the same error. The main object serializes and deserializes correctly, but the array inside doesn’t. The array has the correct number of elements, but no data inside them. I create the object like so:

var obj = { };
obj.selections = new Array();
// customArr holds the data from the select lists and populates fine
$.each(customArr, function(key, value)
{
    if(value== undefined)
       return true;

    obj.selections.push({
        type: value.id,
        subtype: value.subtype,
        model: value.model
    });
}

// Selected comes from data that was previously gathered
if(selected != undefined)
{
    obj.mk = selected.mk;
    obj.md = selected.md;
    obj.yr = selected.yr;
}
obj.id = selectionID;

And I’ve tried two ways of getting the data. I’ve tried to move the page directly:

$.mobile.changePage('/Select/Data/', { data: obj });

and I’ve tried loading the above page without any data (just using the jQuery Mobile data attributes on a hyperlink) and then ajax out for the data using the following:

$.ajax({
    url: '/Select/Data/',
    data: obj,
    type: 'POST',
    datatype: 'json',
    error: function() { // Handle error },
    success: function(response) {
        // Load data
    }
});

If I set breakpoints in my server code I can look at the objects that are returned. The mk, md, and yr properties are populated and the selections array has two objects, but the type, subtype, and model data is empty. However, if I step through the JavaScript code it all gets created exactly as I expect. The POST variables even look right that are sent to the server. Any suggestions?

EDIT: The C# objects look like this:

public class ObjectModel
{
    public int mk;
    public int md;
    public int yr;
    public List<Mod> selections;
}
public class Mod
{
    public int type;
    public int subtype;
    public string model;
}

and the controller method looks like this:

public ActionResult Data(ObjectModel objMod, int id = -1)
  • 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-10T04:39:33+00:00Added an answer on June 10, 2026 at 4:39 am

    Looking at the data that was being passed to the MVC engine showed that the object was being serialized in a JavaScript fasion. Namely, the objects looked like Obj[0]["id"]=5&Obj[0]["name"]="Bob"&Obj[1]["id"]=7&Obj[1]["name"]="Joe". MVC apparently has a hard time deserializing this style of object notation. My solution was to create a simple regex string replace method that took the string jQuery created and then replace it with what MVC was looking for. The regex looked for the ][ pattern since this will only happen in one place for each object and replaced it with a .. Then it looked for the .".+"] and replaced the last character with an empty string. The query string ended up looking like Obj[0].id=5&Obj[0].name="Bob"&Obj[1].id=7&Obj[1].name="Joe". MVC was correctly able to interpret this string. I don’t know if this is a fault with MVC or the way jQuery serializes JS objects, but it’s a pain. Hopefully someone can post a better response.

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

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

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.