将变量传递给javascript回调函数

时间:2016-07-04 14:28:14

标签: javascript ajax callback

我想在JavaScript中将变量传递给回调函数,但我没有找到一种简单直接的方法(不使用全局变量等)。这是我的代码:

$(".delete-sign").click(function(event) {
    var imgId = this.id;
    bootbox.confirm("Are you sure?", function(response) {
        if (response == true) {
            $.ajax({
                url:'delete_keyframes.php',
                type:"POST",
                data: { id: imgId },
                success:function(){ alert("Deleted keyframe"); }
            });
            $("#img-div-"+imgId).remove();
        }
    });     
});

我想在回调函数中传递 imgId 变量。我该怎么办?

0 个答案:

没有答案