【发布时间】:2016-12-07 11:22:42
【问题描述】:
我目前正在制作一个可排序的表,并且需要传递的不仅仅是 id 到序列化数组。
我添加了除 post 文件之外的所有代码,这些代码除了 var_dumping post 之外还可以做任何事情。
<!DOCTYPE html>
<html lang="en">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12"><br><br><br><br>
<table class="display table table-striped table-hover table-bordered dt-responsive responsive nowrap" cellspacing="0" width="100%">
<thead>
<th>Navn</th>
<th>Order</th>
</thead>
<tbody id="sortable">
<tr id="order_1" data-extravalue="45">
<td>value</t>
</tr>
<tr id="order_2" data-extravalue="56">
<td>value</t>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
$('#sortable').sortable({
update: function( event, ui ) {
var order = $("#sortable").sortable('serialize');
$.ajax({
data: order,
type: 'POST',
url: 'post.php'
});
}
});
});
</script>
</body>
</html>
【问题讨论】:
-
首先,您应该正确关闭
<td>标签:<td></td>。其次,您还想收集哪些其他信息?
标签: jquery jquery-ui jquery-ui-sortable