0

I want to pass a variable to a callback function in JavaScript but I haven't found an easy and straightforward way (without using global variables etc). Here's my code:

$(".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();
        }
    });     
});

I want to pass the imgId variable inside the callback function. What should I do?

pap-x
  • 564
  • 1
  • 8
  • 15

0 Answers0