1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| $("#form-bibli").submit(function() {
var form = $(this);
if ("1" === $("#action_check").val()) {
$("#dialog")
.html("Oui\xA0: Confirmer.<br />Non\xA0: Annuler")
.dialog({
title: "Supprimer\xA0?",
buttons: {
"Oui": function() {
var $thisDialog = $(this)
.html("<img src='spinner.gif' alt='' /> Chargement
");
$.ajax({
data: form.serialize(),
method: form.attr("method") || "GET",
url: form.attr("action") || "",
})
.done(function(data) {
console.log(data);
$thisDialog
.dialog("option", { title: "Succès" })
.html("Suppression réussie\xA0!");
})
.fail(function(jqxhr, status, error) {
console.error(error);
$thisDialog
.dialog("option", { title: "Échec" })
.html("Il y a eu une erreur, veuillez réessayer.");
})
.always(function() {
$thisDialog.dialog("option", {
buttons: {
"Ok": function() {
$(this).dialog("close");
}
}
});
});
},
"Non": function() {
$(this).dialog("close");
}
}
});
}
return false;
}); |
Partager