小编Gre*_*rep的帖子

Jquery按钮单击事件未触发

看起来像一个简单的问题,但其他问题的解决方案似乎并不适用于我.

尝试从按钮单击触发AJAX请求,但似乎没有触发.

示例HTML

<button class="remove_weight_button" id="15">x</button>
Run Code Online (Sandbox Code Playgroud)

JavaScript的

$(".remove_weight_button").click(function(){
    var button_id = $(this).attr("id");
    $.ajax({
        type: "POST",
        url: "weight_tracker_process.php",
        data: {
            weight_id: button_id,
            action: "remove"
        },
        success: function(){
            getWeightData();
        },
        error: function(){
            alert("data removal error");
        }
    });
    return false;
});
Run Code Online (Sandbox Code Playgroud)

html javascript ajax jquery

35
推荐指数
1
解决办法
5万
查看次数

标签 统计

ajax ×1

html ×1

javascript ×1

jquery ×1