jQuery sortable不会获得order var

时间:2013-10-14 17:05:39

标签: php jquery

我有这个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没有得到值。我该如何解决?

1 个答案:

答案 0 :(得分:0)

您的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