diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 82e73186233..17b8c50aff3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5156,8 +5156,9 @@ class Form closeOnEscape: false, buttons: { "'.dol_escape_js($langs->transnoentities($labelbuttonyes)).'": function() { - var options = "&token='.urlencode(newToken()).'"; + var options = "token='.urlencode(newToken()).'"; var inputok = '.json_encode($inputok).'; /* List of fields into form */ + var page = "'.dol_escape_js(!empty($page) ? $page : '').'"; var pageyes = "'.dol_escape_js(!empty($pageyes) ? $pageyes : '').'"; if (inputok.length>0) { $.each(inputok, function(i, inputname) { @@ -5174,13 +5175,19 @@ class Form options += "&" + inputname + "=" + encodeURIComponent(inputvalue); }); } - var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "") + options; - if (pageyes.length > 0) { location.href = urljump; } + if (pageyes.length > 0) { + var post = $.post( + pageyes, + options, + (data) => {$("body").html(data)} + ); + } $(this).dialog("close"); }, "'.dol_escape_js($langs->transnoentities($labelbuttonno)).'": function() { - var options = "&token='.urlencode(newToken()).'"; + var options = "token='.urlencode(newToken()).'"; var inputko = '.json_encode($inputko).'; /* List of fields into form */ + var page = "'.dol_escape_js(!empty($page) ? $page : '').'"; var pageno="'.dol_escape_js(!empty($pageno) ? $pageno : '').'"; if (inputko.length>0) { $.each(inputko, function(i, inputname) { @@ -5191,9 +5198,13 @@ class Form options += "&" + inputname + "=" + encodeURIComponent(inputvalue); }); } - var urljump=pageno + (pageno.indexOf("?") < 0 ? "?" : "") + options; - //alert(urljump); - if (pageno.length > 0) { location.href = urljump; } + if (pageno.length > 0) { + var post = $.post( + pageno, + options, + (data) => {$("body").html(data)} + ); + } $(this).dialog("close"); } }