【问题标题】:unable to pass jquery sortable value through ajax无法通过 ajax 传递 jquery 可排序值
【发布时间】:2014-08-24 08:10:17
【问题描述】:

我有两个表,我已经使它们可排序,但唯一缺少的是我现在无法通过 ajax 传递可排序的表值。只是我在某处做的一个小错误。这里是 jsfiddle:demo 这是我的代码: 仪表盘.php

<pre>
    <div id="info"></div>
    </pre>  
    <div id="widget_update">
    <div id="Fahrzeuge" /><img src="/admin/images/arrow.png" alt="move" width="16" height="16" class="handle" />
        <table width="538" cellspacing="0" cellpadding="0" border="0" >
        <tr>
            <td id="fahrzeuge">

            </td>
        </tr>
    </table>
    </div>
    <div id="NEWS" /><img src="/admin/images/arrow.png" alt="move" width="16" height="16" class="handle" />
        <table width="538" cellspacing="0" cellpadding="0" border="0">
        <tr>
            <td id="news">          
            </td>
        </tr>
    </table>
    </div>
    </div>

dashboard.js

$("#widget_update").sortable({
      handle : '.handle',
      update : function () {
          var widget = $('#widget_update').sortable('serialize');         
        $.ajax({
        type: "POST",
        url: "ajax/dashboard.php",
        dataType : 'json',
        cache: false,
        data: {'aktion' : 'show-widget','widget':widget},
        success: function(data){
            $('#widget').html(data.html);
            //location.reload();    
            //showwidget();                 
        },
        error: function(data){
            alert('Cant delete all widget!!!! Press cancel to go back main menu!!!!');
            //location.reload();
        }
        });
      }
});      

【问题讨论】:

  • The button id is same for both the tables。 id 在 html 文档中应该是唯一的。
  • 正如您在 js 中看到的,按钮 id 是 removewidgetId ....我想动态地制作它,这样我就不想每次都为每个选择框选项使用按钮 ....
  • 调用时需要将表id作为参数传递给getremovewidgt()
  • 是的,我试过但不知道如何在 javascript 中编写或调用表 id。我想我必须使用循环或什么?

标签: javascript php jquery ajax html-table


【解决方案1】:

不完全确定您想要在按钮功能方面实现什么,但重要的是要注意 jQuery live() function 在 jQuery 1.7 中已被弃用。

【讨论】:

    猜你喜欢
    • 2019-11-26
    • 1970-01-01
    • 2014-03-31
    • 1970-01-01
    • 1970-01-01
    • 2021-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多