我想在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 变量。我该怎么办?