// I'm trying to pop an alert if an error occurs
// I call delfile to delete a file
// <a href="/path/to/delete" onclick="delfile(this, id_of_the_file)"/>
// The delete part is working ok, but AJAX never returns an error (HTTP/1.1 500)
// This way it does not work
$(function() {
$('#fileinfo').bind('ajaxError', function(error) {
alert("Erro! " + error);
})
});
function delfile(link, div) {
if(confirm('You sure ?')) {
$.get(link.href, {}, function() {
$('#' + div).fadeOut().remove();
});
}
return false;
}
// This way it works
// BUT the second time I delete a file, two errors pop
// The third time, three errors pop... and so on!
function delfile(link, div) {
$('#fileinfo').bind('ajaxError', function(error) {
alert("Erro! " + error);
})
if(confirm('You sure ?')) {
$.get(link.href, {}, function() {
$('#' + div).fadeOut().remove();
});
}
return false;
}