jquery - How to use serialized and send ajax (johnny sortable plugin) -
i use http://johnny.github.io/jquery-sortable/
i can not understand how send serialized data?
my html
<ul> <li data-id="1">item 1</li> <li data-id="2"> item 2 <ul> <li data-id="4">item 4</li> <li data-id="5">item 5</li> </ul> </li> <li data-id="3">item 3</li> </ul>
js
$(function () { $("ul#menulist").sortable({ handle: 'i.icon-move', itemselector: 'li', placeholder: '<li class="placeholder"/>', ondrop: function (item, container, _super) { //var datatosend = $("ul#menulist").sortable("serialize").get(); $.ajax({ url: "ajax_action.php", type: "post", data: datatosend, cache: false, datatype: "json", success: function() {} }); //_super(item, container); } }); });
i tried described in this question, not work ul->li
i need array
[0] => array ( [id] => 1 ) [1] => array ( [id] => 2 [children] => array ( [0] => array ( [id] => 4 ) [1] => array ( [id] => 5 ) ) ) [2] => array ( [id] => 3 )
i grateful help.
you need change serialize
function. here http://jsfiddle.net/985mg/
the plugin allows multiple nested lists in 1 list item. 1 additional level in default data serialization.
Comments
Post a Comment