Intercepting a jQuery.ajax() call with confirm()

后端 未结 1 1762
粉色の甜心
粉色の甜心 2020-12-24 07:38

I have an ajax call bound to a link via jQuery, and I want it intercepted by a confirm dialog. But the ajax call fires regardless of which option is selected (even if the us

相关标签:
1条回答
  • 2020-12-24 07:54
    $('.removeItem').click(function (event) {
        if (confirm('Are you sure you want to delete this?')) {
            $.ajax({
                url: 'myUrl',
                type: "POST",
                data: {
                    // data stuff here
                },
                success: function () {
                    // does some stuff here...
                }
            });
        }
    });
    
    0 讨论(0)
提交回复
热议问题