title: How to make Ajax delete Django's object instance?
body: <p>There is a list generated in HTML, that represents all objects (Cards).
   There is already a delete button, but it's using Django functionality, and it requires a page to reload to take effect.
   Is there a simple way to include AJAX into the program?</p>
  
  <p>I am a beginner to JavaScript and AJAX. I have tried some copy-paste solutions. I even tried to deconstruct a simple Django Ajax CRUD app, but it has too many functionalities, and it seemed like an overkill for my app (i would have to rewrite all the views, templates and urls).
   So I decided to ask a question over here with my own code. </p>
  
  <p>views.py (List objects view)</p>
  
  <pre><code>def all_cards(request):
      cards = Card.objects.all()
      return render(request, 'all_cards.html', {'cards':cards})
  </code></pre>
  
  <p>all_cards.html</p>
  
  <pre><code> &lt;body&gt;
      {% if cards %}
      &lt;table class="table" id="card-table"&gt;
        &lt;tr&gt;
          &lt;th&gt;Card owner name&lt;/th&gt;
          &lt;th&gt;Card balance&lt;/th&gt;
        &lt;/tr&gt;
        {% for card in cards %}
        &lt;tr&gt;
          &lt;td&gt;{{ card.cardholders_name }}&lt;/td&gt;
          &lt;td&gt;{{ card.card_balance }}€&lt;/td&gt;
          &lt;td&gt;&lt;form action="{% url 'card_delete' card.id %}" method="post"&gt;
              {% csrf_token %}
            &lt;input type="submit" value='Delete'&gt;
        &lt;/form&gt;&lt;/td&gt;
        &lt;/tr&gt;
        {% endfor %}
        {% else %}
        &lt;p&gt;There are no cards registered.&lt;/p&gt;
        {% endif %}
      &lt;/table&gt;
    &lt;/body&gt;
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>    url(r'(?P&lt;id&gt;\d+)/$', views.card_delete, name='card_delete'),
  </code></pre>
  
  <p>views.py (Delete object view)</p>
  
  <pre><code>def card_delete(request, id):
      card_that_is_ready_to_be_deleted = get_object_or_404(Card, id=id)
      if request.method == 'POST':
          card_that_is_ready_to_be_deleted.delete()
  
      return HttpResponseRedirect('/all_cards')
  </code></pre>
  
  <p>As you can see, the form's input(
  <code>&lt;input type="submit" value='Delete'&gt;</code>
  )calls Django's view via URL.</p>
  
  <p>I expect the delete button to call an AJAX functionality, that will do a similar thing.</p>
  
  <p>How should I go about writing that functionality?</p>
  
  <p>P.S.: This is my first StackOVerflow question, I'm open for constructive criticism.</p>