title: Delete data from mongoose using checkbox (Node JS w/ AJAX)
body: <p>I am trying to delete data from Mongo DB (mongoose in this case) using Node JS (w/ Express), and JQuery AJAX. </p>
  
  <p>So, there are checkboxes with a data near them (interface). When I check one or more of these checkboxes, and then press SUBMIT, I want them to be deleted from database (Mongo DB). </p>
  
  <p>Thus, I tried using DELETE request, getting data from AJAX, and then removing it from DB (using Model.remove() ), but as soon as I want to get req.params (in order to remove item from db), I do get only 'undefined'. I think something is wrong with my Ajax, but not sure what exactly.</p>
  
  <h2>Express</h2>
  
  <pre><code>    app.delete('/index', function(req,res){
  
      console.log("req body: " + req.body); // Undefined?
      console.log(req.params.del); // Undefined as well
      console.log(req.params.data); // Undefined as well
  
      Blog.remove({item: req.params.del}, function(err, data){
          if (err) throw err;
          res.json(data);
      });
  });
  </code></pre>
  
  <h2>AJAX</h2>
  
  <pre><code>    $('#deleteAcc').on('click', function(){
        //var item = $(this).text().replace(/ /g, "-");
        var item = $(".checkbox input:checked").parent();
        item.remove();
        $.ajax({
          type: 'DELETE',
          url: '/index',
          del: item,
          success: function(data){
            //do something with the data via front-end framework
            location.reload();
          }
        });
    });
  </code></pre>
  
  <h2>HTML</h2>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;Simple blogging website&lt;/title&gt;
      &lt;script
        src="https://code.jquery.com/jquery-1.12.4.min.js"
        integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
        crossorigin="anonymous"&gt;&lt;/script&gt;
      &lt;link href="/assets/styles.css" rel="stylesheet" type="text/css" /&gt;
      &lt;script src="/assets/appAJAX.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;h1 align="center" size="40px"&gt;Welcome to blog!&lt;/h1&gt;
      &lt;h2 align="center" size="36px"&gt;Best UX/UI Website ever!&lt;/h2&gt;
      &lt;form style="text-align: center;"&gt;
          &lt;input style="width: 400px; height: 125px;" type="text" name="inputText" placeholder="Piss someone off..." required/&gt;
          &lt;button type="submit"&gt;Submit post&lt;/button&gt;
      &lt;/form&gt;
      &lt;br&gt;
      &lt;div class="control-group"&gt;
          &lt;% for (var i = 0; i &lt; posts.length; i++) { %&gt;
          &lt;label class="checkbox"&gt;
              &lt;input type="checkbox" /&gt;&lt;%= posts[i].item %&gt;
          &lt;/label&gt;
          &lt;% } %&gt;
      &lt;/div&gt;
      &lt;div class="btn"&gt;
          &lt;button type="button" id="deleteAcc"&gt;Delete&lt;/button&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>