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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:41:42+00:00 2026-05-14T02:41:42+00:00

Third try at fixing this tonight – trying a different approach than before now.

  • 0

Third try at fixing this tonight – trying a different approach than before now.

Given a jQuery Sortable List..

<ul id="sortable1" class="connectedSortable">
    <li class="ui-state-default" id="item1">Item 1</li>
    <li class="ui-state-default" id="item2">Item 2</li>
    <li class="ui-state-default">Item 3</li>
    <li class="ui-state-default ">Item 4</li>
    <li class="ui-state-default">Item 5</li>
</ul>

<ul id="sortable2" class="connectedSortable">
</ul>

And ASP.NET MVC ActionResult..

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Insert( string[] items )
    {
        return null;
    }

Activated by JavaScript…

        $("#sortable1, #sortable2").sortable({
            connectWith: '.connectedSortable',
            dropOnEmpty: true,
            receive: function () {
                var items = $(this).sortable('toArray');
                alert(items);
                $.ajax({
                    url: '/Manage/Events/Insert',
                    type: 'post',
                    data: { 'items': items }
                });
            }
        }).disableSelection();

The ‘alert’ DOES show the right items. It shows ‘item1, item2’ etc. But my ASP.NET MVC ActionResult gets nothing. The method DOES fire, but the ‘items’ parameter comes in null. Any ideas?

  • 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-14T02:41:43+00:00Added an answer on May 14, 2026 at 2:41 am

    Looks like serialization issue was addressed in jQuery 1.4.2 (See related question).


    Original answer:
    I sorta figured out the answer, but you will most likely not like it =).

    Looking at the form post example on Phil Haack’s blog, as long as your input elements all have the same name they’ll be put into a list. I tried mapping the array of strings to an array of objects like so:

    var items = $.map( 
        $(this).sortable('toArray'),
        function(item, index){
            return {"item": item};
        }
    );
    
    $.ajax({
        url: '/Home/Insert',
        type: 'post',
        data: { items: items }
    });
    

    and when I did the submit I got a non null array of the correct length, but each cell was null. The problem was that (according to firebug) the POST params looked like this:

    items[0][item]  item1
    items[1][item]  item2
    

    which is close to what I want, but not quite there. What I really wanted to submit was something that looks like this:

    items   item1
    items   item2
    

    because that’s essentially what the form in Phil’s example is doing. I don’t know how to get JSON to serialize like that so I cheated and created the string by hand like so:

    $.ajax({
        url: '/Home/Insert',
        type: 'post',
        data: 'items=items1&items=items2'
    });
    

    This worked. When I checked the value of the items array in the action, it had two strings in it “item1” and “item2”. So it looks like you can get your code to work by serializing the data by hand (so to speak) and using the string as an argument in your ajax call. Somehow this feels like the wrong way to go, so I hope someone corrects me with a way that is/feels more right.

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

Sidebar

Related Questions

THIRD EDIT: I now believe that this problem is due to a SOAP version
I'll try this again. I need help in getting a third option working using
This is the very first time I try to import a third party *.jar
I'm trying to interact with a third party application but whenever I try and
I encountered this problem using a third party library provided by a different group
A third party developer my boss has brought in, designed a Better System than
So I am using Jquery mobile with great success except for one issue. Now
I'm trying this simple code, but the damn break doesn't work... what is wrong?
when I try to use a third part module in my perl script, I
I'll try to explain this as best as I can. I have a form

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.