title: Pass php value with ajax with ajax post
body: <p>I'm using an ajax script to post a value to a PHP file.
  I'm not able to pass the variable.</p>
  
  <p>My variable is declared in PHP and I would like to pass it with ajax.</p>
  
  <p>Here is the variable and my button: </p>
  
  <pre><code>&lt;?php $employee_id= '3'; ?&gt;    
  &lt;input class="btn btn-danger" type="submit" value="Delete" id="delete-btn"&gt;
  </code></pre>
  
  <p>This is the Javascript:</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function () {
          $("input#delete-btn").click(function(){
              $.ajax({
                  type: "POST",
                  url: "delete.php", // 
                  data: {id: '$employee_id'},
                  success: function(msg){
                      $("#thanks").html(msg)  
                  },
                  error: function(){
                      alert("failure");
                  }
              });
          });
      });
      &lt;/script&gt;
  </code></pre>
  
  <p>Here is the PHP code where I want to receive the value:</p>
  
  <pre><code>if (isset($_POST['id'])) {
  
  $emp_id = strip_tags($_POST['id']); 
  
  echo $emp_id;
  
  $query = "DELETE FROM `employee` WHERE id='$emp_id'"; 
  
  $result = mysql_query($query) OR die(mysql_error()); 
  
  echo 'You successfully deleted the user.';}
  </code></pre>
  
  <p>I know I'm doing something wrong around the data...</p>