Do you also need ajax without jQuery? What is the reason for abandoning jQuery? No need to reinvent the bikes, use the ready-made jquery sortable plugin
Page
<script> $(function() { $("#sortable").sortable( { cursor: 'move', update: function() { $.ajax({ url: '<?=$site_link;?>/sort_save/', // ссылка на обработчик type: "POST", data: { order: $('#sortable').sortable("toArray") }, success: function (data) { // обработка если надо }, error: function () { // обработка если надо }); } }); $("#sortable").disableSelection(); }); </script> <ul id="sortable"> <!-- Массив для сортировки с id записи и именем --> <?if($array):foreach($array as $item):?> <li id="sort-<?=$item['id'];?>"><?=$item['name'];?></li> <?endforeach; endif;?> </ul>
Handler on the server
function sort_save(){ $error = false; $order = $_POST['order']; foreach($order as $i=>$id){ $post['sort'] = $i; $id = str_replace("sort-", "", $id); $result = base::sql_edit("my_table", $post, "where id_sitemap = '$id'"); // update в базе if(!$result) $error = true; } if($error){ // обработка ошибки } }