It looks like the serialization issue was addressed in jQuery 1.4.2 (see related question ).
Original answer:
I figured out the answer, but you most likely will not like it =).
Looking at the Phil Haack blog post form , as long as your input items have the same name, they will be put on the list. I tried to match an array of strings with an array of such objects:
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 submit, I got a zero array of the correct length, but each cell was zero. The problem was that (according to firebug) the POST parameters 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 introduce was as follows:
items item1 items item2
because this is what form does in Phil's example. I don't know how to get JSON to serialize so that I cheat and create a line manually:
$.ajax({ url: '/Home/Insert', type: 'post', data: 'items=items1&items=items2' });
It worked. When I checked the value of the items array in action, it had two lines in it, "item1" and "item2". So it looks like you can make your code work by serializing the data manually (so to speak) and using the string as an argument in your ajax call. Somehow, this seems like the wrong way, so I hope someone corrects me in a way that will / feels more correct.
R0MANARMY
source share