jquery ui 可排序列表发送 ajax 元素的更新顺序

jquery ui sortable list send updated order of of elements with ajax

我需要像 item1=1&item2=2&item3=3 这样的所有元素的顺序,只要对一个元素进行排序。这是该代码的 js fiddle。由于缩进错误,无法粘贴为 link。

Fiddle: jsfiddle.net/8s8t99r7/2/

var order = [],
    counter = 1;

$('.sortable').sortable({
    connectWith: ".connectedSortable",
    cursor: "move",
    update: function(event, ui) {
        order = [];
        counter = 1;
        $('.sortable div').each(function() {
            order.push($(this).attr('id') + "=" + counter++);
        });
        alert(order.join('&'));
    }
}).disableSelection();

演示:https://jsfiddle.net/tusharj/8s8t99r7/4/