Here’s the ajax
$('#delete_button').live('click', function(e){
e.preventDefault();
confirmDelete();
$.ajax({
url: del_link,
dataType: 'json',
success: function(data) {
location.replace(data.redirect_url);
}
});
});
and in a separate JS file I have
function confirmDelete() {
return confirm('Are you sure you want to delete?');
}
When I click ‘Cancel’ on the confirm dialog, the Ajax runs (when it should not).
What am I doing wrong?
In your live function, replace
with: