title: NodeJs delete request via jQuery/ajax
body: <p>I have this code on server side </p>
  
  <pre><code> router.delete('/categories/delete/:id', function(req,res){
           var id = req.params.id;
            Category.remove({_id: id},function(err){
                 if(err){
                      console.log(err);
                 }
                 req.flash('success','Category Deleted');
                 res.location('/manage/categories');
                 res.redirect('/manage/categories');
            });
      });
  </code></pre>
  
  <p>In dustjs view I have this button <code>&lt;a href="#" class="removeCategory button tiny alert" data-id="{._id}"&gt;Delete&lt;/a&gt;</code></p>
  
  <p>And in the script file i have </p>
  
  <pre><code>$(document).ready(function(){
      $('.removeCategory').on('click', function(e){
          $target =  $(e.target);
          var id = $target.attr('data-id');
          $.ajax({
              type: 'DELETE',
              url: '/manage/categories/delete/'+id,
              success: function(response){
                  alert('Delete');
                  window.location = '/manage/categories';
              },
              error: function(err){
                  console.log(err);
              }
  
          });
      });
  
  });
  </code></pre>
  
  <p>The thing is that it kinda works but the category disappears only after I refresh the page but when i have  look at the console I get a message like this:</p>
  
  <pre><code>abort: function abort()
  ​
  always: function always()
  ​
  complete: function add()
  ​
  done: function add()
  ​
  error: function add()
  ​
  fail: function add()
  ​
  getAllResponseHeaders: function getAllResponseHeaders()
  ​
  getResponseHeader: function getResponseHeader()
  ​
  overrideMimeType: function overrideMimeType()
  ​
  pipe: function then()
  ​
  progress: function add()
  ​
  promise: function promise()
  ​
  readyState: 4
  ​
  responseText: "&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n&lt;meta charset=\"utf-8\"&gt;\n&lt;title&gt;Error&lt;/title&gt;\n&lt;/head&gt;\n&lt;body&gt;\n&lt;pre&gt;Cannot DELETE /manage/categories&lt;/pre&gt;\n&lt;/body&gt;\n&lt;/html&gt;\n"
  ​
  setRequestHeader: function setRequestHeader()
  ​
  state: function state()
  ​
  status: 404
  ​
  statusCode: function statusCode()
  ​
  statusText: "Not Found"
  ​
  success: function add()
  ​
  then: function then()
  </code></pre>
  
  <p>I also want to mention that the alert box never appears. Does anyone know how to fix this issue? Thank you in advance</p>