title: return php variable to jquery ajax
body: <p>I have an ajax function in jquery calling a php file to perform some operation on my database, but the result may vary. I want to output a different message whether it succeeded or not</p>
  
  <p>i have this :  </p>
  
  <pre><code>echo '&lt;button id="remove_dir" onclick="removed('.$dir_id.')"&gt;remove directory&lt;/button&gt;';
  
  &lt;script type="text/javascript"&gt;
      function removed(did){
          $.ajax({ 
              type: "POST", 
              url: "rmdir.php", 
              data: {dir_id: did},
              success: function(rmd){ 
                  if(rmd==0)
                      alert("deleted");
                  else
                      alert("not empty");
                  window.location.reload(true);
              } 
          }); 
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>and this </p>
  
  <pre><code>   &lt;?php
  require('bdd_connect.php');
  require('functions/file_operation.php');
  if(isset($_POST['dir_id'])){
      $rmd=remove_dir($_POST['dir_id'],$bdd);
  }
  ?&gt;
  </code></pre>
  
  <p>my question is, how to return $rmd so in the $.ajax, i can alert the correct message ?</p>
  
  <p>thank you for your answers</p>