title: I am trying to learn ajax within wordpress to delete a table entry but am getting confused on placement
body: <p>I have created a wordpress addon to add fixtures and results for sports team within different leagues, you can view fixtures and results for each league and delete/edit them as needed.</p>
  <p>I have added a button at the end named Delete, and when I click that button I would like it to delete the entry from the table and make the whole entry disappear with a fade.</p>
  <p>I have been looking up websites on how ajax works with wordpress but am getting confused.</p>
  <p>This is my button code and javascript on the fixtures_admin.php page within my plugin.</p>
  <pre><code>&lt;input type=&quot;button&quot; id=&quot;&lt;?php echo $elementid; ?&gt;&quot; class=&quot;submitDeleteEntry&quot; name=&quot;submitDeleteEntry&quot; value=&quot;Delete&quot; /&gt;
  
  &lt;script type=&quot;text/javascript&quot;&gt;
      jQuery(document).on('click', '.submitDeleteEntry', function () {
          var id = this.id;
          //alert(id);
          jQuery.ajax({
              type: 'POST',
              url: ajaxurl,
              data: {&quot;action&quot;: &quot;fws_delete_row&quot;, &quot;id&quot;: id},
              success: function (data) {
                 
              }
          });
       });
  &lt;/script&gt;
  </code></pre>
  <p>The $elementid is just using the variable id from the database and works as intended.</p>
  <p>If I uncomment the alert(id); line I do get an alert with the id.</p>
  <p>I have placed this code at the top of the page registering the ajax</p>
  <pre><code>function fws_delete_row(){
      global $wpdb;
      $dbtable = $wpdb-&gt;prefix . 'fws_fixtures';
      $id = $_POST['id'];
      $wpdb-&gt;delete($table, array('id' =&gt; $id));    
  }
  add_action( 'wp_ajax_fws_delete_row', 'fws_delete_row' );
  add_action( 'wp_ajax_nopriv_fws_delete_row', 'fws_delete_row' );
  </code></pre>
  <p>But when I click the delete button nothing happens. I have tried looking around the internet for examples of how to do it but can't seem to find the way to do it.</p>
  <p>I am happy to come to the conclusion myself but if someone could please explain to me where I am going wrong I would really like to learn.</p>
  <p>I know once the delete happens from the database I will need to add more code in for the line to be deleted on the page but for now I just want to get the button at least deleting.</p>
  <p>I thank you so much for your help.</p>