troubleshooting Question

JQuery Refresh DIV after sorting (Code provided)

Avatar of Wayne Barron
Wayne BarronFlag for United States of America asked on
ASPAJAXjQuery
8 Comments1 Solution13 ViewsLast Modified:
Hello, All.

I am working with a JQuery Sorting table.
Love it, works great.
However, I am trying to make it do an auto-update-refresh, so it will get the new sorting numbers as they are entered into the database.

The first time it is run, it works. However, anytime after the first time, it will not auto-update-refresh the data in the table.

This is what I am calling when the sorting is over.
<table id="SongList">
This is what I am using.

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<script type="text/javascript">
$(function() {
   $("#sortable").sortable(    
      {opacity: 0.7,
       revert: true,
       scroll: true, 
      cursor: 'crosshair', 
      update : function () { 
               var order = $('#sortable').sortable('serialize'); 
         //alert(order);
               $("#info").load("Insert.asp?"+order);
            //Refresh when we are done sorting, to get the new ordered list
             $('#SongList').load('SongList.asp?DJID=1&chID=1');
         }
   });
});
</script>
                    
<div id="info">Order your songs</div>
        <table class="table table-bordered" id="SongList" style="width:420px; font-size:10pt; color:#CCC;">
            <tr>
                <th style="width:5%;">#</th>
                <th style="width:15%;">Order</th>
                <th style="width:100%;">Song Title</th>
                <th style="width:20%;">Artist</th>
            </tr>
            <tbody class="row_position" id="sortable">
         
                <tr id="favItem_49" class="dragit">
                <td style="border-bottom:1px double #CCC;">0</td>
                    <td style="border-bottom:1px double #CCC;">49</td>
                    <td style="border-bottom:1px double #CCC;">Strutter</td>
                    <td style="border-bottom:1px double #CCC;">KISS</td>
                </tr>
            
                <tr id="favItem_48" class="dragit">
                <td style="border-bottom:1px double #CCC;">1</td>
                    <td style="border-bottom:1px double #CCC;">48</td>
                    <td style="border-bottom:1px double #CCC;">Do You Love Me</td>
                    <td style="border-bottom:1px double #CCC;">KISS</td>
                </tr>

                <tr id="favItem_37" class="dragit">
                <td style="border-bottom:1px double #CCC;">2</td>
                    <td style="border-bottom:1px double #CCC;">37</td>
                    <td style="border-bottom:1px double #CCC;">Who Wants to be Lonely</td>
                    <td style="border-bottom:1px double #CCC;">KISS</td>
                </tr>
            
                <tr id="favItem_65" class="dragit">
                <td style="border-bottom:1px double #CCC;">3</td>
                    <td style="border-bottom:1px double #CCC;">65</td>
                    <td style="border-bottom:1px double #CCC;">Tears are Falling</td>
                    <td style="border-bottom:1px double #CCC;">KISS</td>
                </tr>
            
                <tr id="favItem_43" class="dragit">
                <td style="border-bottom:1px double #CCC;">4</td>
                    <td style="border-bottom:1px double #CCC;">43</td>
                    <td style="border-bottom:1px double #CCC;">Love 'em and Leave 'em</td>
                    <td style="border-bottom:1px double #CCC;">KISS</td>
                </tr>
            
</tbody>
</tr>
</table>

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros