weixin_33697898 2016-11-01 16:49 采纳率: 0%
浏览 25

遍历序列化数据

I want to use jqueryui sortable to reorder columns in a table by dragging and dropping, however I don't know how to even return the data to the POST action, let alone loop through it.

I am generating my <ul> like so:

<ul id="sort">
    @foreach (var item in Model)
    {
        <li id="id_@Html.DisplayFor(modelItem => item.Id)">@Html.DisplayFor(modelItem => item.Title)</li>
    }
</ul>

This is the sortable js code:

$('#sort').sortable({
            update: function () {
                var ids = $('#sort').sortable('serialize');
                var url = "/admin/cms/ReorderPages";
                $.post(url, ids, function (data) {
                    $("#msg").html(data);
                });
                console.log(ids);
            }
        });

And my POST method:

[HttpPost]
        public string ReorderPages(string ids)
        {
            return ids;
        }

Upon dragging and dropping I get the following console logged:

id[]=1&id[]=4&id[]=2&id[]=3&id[]=14

So that part works, but how do I get that into my POST action and loop through it to get the ids?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度