如何使用序列化和发送AJAX(约翰尼排序插件)如何使用、插件、约翰尼、序列化

由网友(赠)分享简介:我用 http://johnny.github.io/jquery-sortable/ 我不明白如何发送序列化的数据?I can not understand how to send the serialized data?我的HTML Item 1
  • 我用 http://johnny.github.io/jquery-sortable/

    我不明白如何发送序列化的数据?

    I can not understand how to send the serialized data?

    我的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);
            }
        });
    });
    

    我想在this问题,但它不与 UL->里工作

    我需要一个数组

    [0] => Array
    (
        [id] => 1
    )
    [1] => Array
    (
        [id] => 2
        [children] => Array
        (
            [0] => Array
            (
                [id] => 4
            )
            [1] => Array
            (
                [id] => 5
            )
        )
    )
    [2] => Array
    (
        [id] => 3
    )
    

    我会很感激你的帮助。

    I would be grateful for your help.

    推荐答案

    您需要更改连载功能。看看这里 http://jsfiddle.net/985Mg/

    You need to change the serialize function. Look here http://jsfiddle.net/985Mg/

    该插件允许多个嵌套列表中的一个列表项。因此,你在默认的数据序列化一个额外的水平。

    The plugin allows multiple nested lists in one list item. Thus you get one additional level in the default data serialization.

  • 阅读全文

    相关推荐

    最新文章