Sortable connected lists to mysql problem

Sortable connected lists to mysql problem

Hello,

I have the lists working correctly, and posting data to a php script to update the database, however the data does not accurately represent the changes to the lists.  I'm a beginner with jquery, and doing this largely from examples from the web.  Any help appreciated.

Consider the following connected lists:

If I were to grab '1507' from the first list, and drop it between 1496 and 1497 on the second list, I get the following data POSTed to my php script:

  1. 
    sort0 Array
    (
        [1603] => Array
            (
                [0] => 1505
                [1] => 1506
                [2] => 1508
                [3] => 1509
                [4] => 1510
            )
    
    )
    
    
    sort1 Array
    (
        [0702] => Array
            (
                [0] => 1493
                [1] => 1494
                [2] => 1495
                [3] => 1496
                [4] => 1497
            )
    
        [1603] => Array
            (
                [0] => 1507
            )
    
    )
    
    
    sort2 Array
    (
        [0708] => Array
            (
                [0] => 1481
                [1] => 1482
                [2] => 1483
                [3] => 1484
                [4] => 1485
    
            )
    
    )
I can surmise that 1507 was dragged from the sort0 list and dropped onto the sort1 list, but not WHERE it was inserted in the sort1 list.

This is the jquery function I am using:
  1. <script type="text/javascript"><!--
    $(function()
    {
          $( "#sortable0, #sortable1, #sortable2, #sortable3, #sortable4" ).sortable(

        {
            connectWith: '.connectedSortable',
            stop : function ()
            {
                $.ajax(
                {
                    type: "POST",
                    url: "save.php",
                    data:
                    {
                        sort0:$("#sortable0").sortable('serialize'),
                        sort1:$("#sortable1").sortable('serialize'),
                        sort2:$("#sortable2").sortable('serialize'),
                        sort3:$("#sortable3").sortable('serialize'),
                        sort4:$("#sortable4").sortable('serialize')
                    },
                    success: function(html)
                    {
                        //$('.success').fadeIn(500);
                    }
                });
            }
        }).disableSelection();
    });
    --></script>