function pageSettings(){ setTriggersOnForm(); } function setTriggersOnForm(){ $("#").submit(function(){ submitMyForm(); return false; }); $("#btn-cancel-refund").click(function(){ confirmOrNotRefund(false); }); $("#btn-validate-refund").click(function(){ confirmOrNotRefund(true); }); }; function submitMyForm(){ showLoading(true); $.ajax({ type: "POST", dataType: "html", data: $("#").serialize(), contentType: "application/x-www-form-urlencoded; charset=UTF-8", url: "/fr/mon-compte/remboursement/?action=submitAjax", success: function(html) { $("#form-container").html(html); setTriggersOnForm(); showLoading(false); }, error: function(req,textStatus,errorThrown){ showLoading(false); myAlert(errorThrown.message); } }); } function confirmOrNotRefund(choice){ showLoading(true); var datas = {}; datas.choice = choice; $.ajax({ type: "POST", dataType: "html", data: datas, contentType: "application/x-www-form-urlencoded; charset=UTF-8", url: "/fr/mon-compte/remboursement/?action=submitConfirm", success: function(html) { $("#form-container").html(html); setTriggersOnForm(); showLoading(false); }, error: function(req,textStatus,errorThrown){ showLoading(false); myAlert(errorThrown.message); } }); }