我有这个js代码
$("#sortable").sortable({
axis: 'y',
handle: '.fancybox',
update: function() {
var order = $('#sortable').sortable('serialize');
$("#sortable").load("inc/ajax/sortable/update2.php?"+order);
alert(order);
}
});然后我用php填充列表:
foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $result)
{
$_SESSION['img'][]=$result['id_imag'];
$img[]="
<div class='highlight-3' width='100%'>
<li id='".$result['id_imag']."'>
<a class='fancybox' href='".$result['den_img']."' data-fancybox-group='gallery' title='Reian Imob' >
<img src='".$result['den_img']."' id='".$result['id_imag']."' ></a>
<a href='#' id='".$result['id_imag']."' class='del' onclick='delete_imag_mod(this);' >Delete</a>
</li>
</div>";
}html:
<ul class="gallery" id="sortable" style="background:#FCFCFC; width:100%">
<?php
$images=$db->select_images ($_POST['vid']);
if($nr_imag>0) {
foreach($images as $val)
{
echo $val;
}
}
?>
</ul>问题是: var order没有得到值。我怎么才能修好它?
发布于 2013-10-14 17:50:34
您的html代码应该如下所示:
<ul id="sortable">
<li id="li_first"> // here undercsore is mandatory
<div>some text</div>
</li>
<li id="li_second"> // here undercsore is mandatory
<div>some text</div>
</li>
</ul>有关更多信息,请查看以下链接:http://api.jqueryui.com/sortable/#method-serialize
https://stackoverflow.com/questions/19365451
复制相似问题