There are several functions, in each of them I want to put a check on the permission to perform this function, but there are nuances
$("#formsubmit").click(function { var operacia = 100; prov_prav(operacia); alert("выполняемся дальше"); // выполнение дальнейшего кода } The verification function itself - Ajax request
function prov_prav(operacia){ var operacia = operacia; alert("Номер операции - "+operacia); jQuery.ajax({ type: "POST", url: "prov_prav_polz.php", dataType:"text", data:{"operacia":operacia}, cache: false, success:function(response){ alert(response); }, error:function (xhr, ajaxOptions, thrownError){ alert(thrownError); alert("Ошибка выполнения скрипта"); } }); } PHP code is just a reconciliation of an existing user id with a set of its capabilities; let's say it’s empty for now, just check what comes up ...
<?php print_r($_POST); $oper_dobavlenia = 0; if($oper_dobavlenia == 1) { echo "Операция разрешена"; } else { echo "Операция запрещена"; exit(); } } ?> PROBLEM!!!
When executing this thread, messages are displayed in the following order.
- Operation Number - 100
- run further
- and only then variable operacia from the POST array
Accordingly, the order of execution is violated, why I do not understand. Although in my mind, you must first 3 message then 2. well, and if in the handler I return false, the function still runs and only then the output is performed.