title: How to call a php function with parameters using Ajax and JQuery
body: <p>Trying to delete a record by using JQuery/Ajax function so that my page will not reload everytime I delete. I have a Movie.php that serves as a model object for Movie and this is where I put the function called delete_movie to delete based on movieId parameter. I have tried to call it inside my Jquery call but it looks like it is not calling my function delete_movie(movieId). </p>
  
  <p>This is my Movie.php</p>
  
  <pre><code>&lt;?php
  
  class Movie {
      public static function delete_movie($movieId) {
          $db = Database::getDB();
  
          $query = 'DELETE FROM MOVIE
                WHERE movieId = :movieId';
          $statement = $db-&gt;prepare($query);
          $statement-&gt;bindValue(':movieId', $movieId);
          $statement-&gt;execute();
          $statement-&gt;closeCursor();
      }
  }
  ?&gt;
  </code></pre>
  
  <p>movielist.php</p>
  
  <pre><code>&lt;tr class="delete_mem&lt;?php echo $movie['movieId'];?&gt;"&gt;
      &lt;td&gt;&lt;?php echo $movie['title']; ?&gt; &lt;/td&gt;
      &lt;td&gt;&lt;?php echo $movie['releaseYear']; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $movie['imdbId']; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;?php echo $movie['description']; ?&gt;&lt;/td&gt;
      &lt;td&gt;&lt;button type="submit" class="btn btn-danger" id="&lt;?php echo $movie['movieId'];?&gt;"&gt;Delete&lt;/button&gt;&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>JQScript.js</p>
  
  <pre><code>$(document).ready(function() {
  $('.btn-danger').click(function() {
      var id = $(this).attr("id");
      if (confirm("Are you sure you want to delete this?")) {
          $.ajax({
              type: "POST",
              url: "model/Movie.php",
              data: {
                  delete_movie : id
              },
              success: function() {
                  alert('Success deletion!');
              }
          });
      } else {
          return false;
      }
  });
  </code></pre>
  
  <p>});</p>