dtyyrt4545 2016-03-03 22:11
浏览 45

我怎么能在PHP中保存jquery ui可排序的顺序

i have new_cats table it contains id, title, order and i post data from the table like this

php

    <table>
    <tbody class="sort">
    <?php
    $select_newscats = $mysqli->query("SELECT * FROM news_cats order by ord_show asc");

    while ($rows_newscats = $select_newscats->fetch_array(MYSQL_ASSOC)){

    $id_newscats          = $rows_newscats ['id'];
    $title_newscats       = $rows_newscats ['title'];
    $order_newscats       = $rows_newscats ['order'];
    ?>
    <tr class="trtable" id="item_<? echo $id_newscats; ?>">
    <td><? echo $id; ?></td>
    <td><? echo $title_newscats; ?></td>
    </tr>
    <?
    }
    ?>
<button class="savesort"></button>
    </tbody>
    </table>

and i have this jquery code to sortable table and trying to update order in database

$(document).ready(function(){
$(".sort").sortable({
        update: function (event, ui) {
            var order = $(this).sortable('serialize');
        }
    }).disableSelection();

$('.savesort').on('click', function () {
var aa = $(".sort").sortable("serialize", {
attribute: "id"
});

var s = {
"aa":aa
}

$.ajax({
data: s,
type: 'POST',
url: 'ajax/save_newscats_ord.php',
success:function(data){
    alertify.success(data);
  }
});
return false;
});

});

in this page save_newscats_ord.phpi tried to save order but i don't get any data from jquery code i tried this code to get data

<?php
$list = $_post['aa'];
echo $list;
?> 

how can i send data to php page and how can i save it in my database in order filed

  • 写回答

1条回答 默认 最新

  • dtoqa66028 2016-03-03 22:16
    关注

    You need to change your PHP code to reference the actual POST variable passed, change this line:

    $list = $_post['aa'];
    

    to

    $list = $_POST['aa'];
    

    Note that the variable names are case sensitive in PHP.

    评论

报告相同问题?

悬赏问题

  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致