After call a php function by ajax how to apply its result for to check another submission <p>If user not banned, user can comment here. So I have a php function to check banned user. In case of comment form submitting, a ajax call 1st check this user is banned or not. If not: comment will be submit else display a massage.</p> <p>Here, I cannot submit any comment if banned or not, Page refresh if I try to submit. In cannot also understand how to apply my <code>banneduser()</code> response to check form submitting.</p> <p>php function: (I dont want change it, because I used it many more case)</p> <pre><code>//user name banned by user function Banned($user){ global $db; if(!get_magic_quotes_gpc()){ $touser = addslashes($user); } $byuser = $_SESSION['user']; $result = mysqli_query($db,"SELECT * FROM blocking WHERE byname = '$byuser' AND toname = '$touser'") or die(mysqli_error($db)); return (mysqli_num_rows($result) &gt; 0); } </code></pre> <p>Ajax: </p> <pre><code>// check banned user function banneduser(){ var Bauthor = $("#author").attr("value"); $.ajax({ type: "POST", url: "../common", data: "action=Banned&amp;user="+ Bauthor, success: function(data){ // How to play with this data if(data){ return false; } } }); return false; } //comment submit if user not banned $(".reply").on("click",function(){ if(banneduser()){ // make form submission } else { // You are banned} }); </code></pre>