dongtan7201 2019-04-07 06:10
浏览 56

使用ajax更新特定的td(表数据)

I'm trying to edit grade using ajax. The showing of modal is okay but there is no data from specific grade.

This is my current code.

                    <td id="<?php echo $row['id']; ?>" data-target="grade"><?php echo $row['grade']; ?><br><small>

                        <a href="#" data-role="update" data-id="<?php echo $row['id']; ?>">Update</a></small>

                        <?php } ?> <?php } ?>
                    </td>

Here's my script

<script>
$(document).ready(function() {
    $(document).on('click','a[data-role=update]', function(){
        var id = $(this).data('id');
        var grade = $('#'+id).children('td[data-target=grade]').text();

        $('#grade').val(grade);
        $('#gradeId').val(id);
        $('#myModal').modal('toggle');
    });
});

I expect that I can only edit the specific grade. Please help me...

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)