I am learning Ajax and I ran into a little problem.
I'm trying to submit a POST request to a django backend with ajax. EVEN the alert won't show up on the screen. And as I see in the test django server shell, it doesn't even submit the POST request.
The code:
<script type="text/javascript">
    $('#btnLike').on('click', function(event) {
     alert('ok');
      $.ajax({
       type: 'POST',
        url: 'http://127.0.0.1:8000/backend/website/like', /* for testig */
        data: {
         csrfmiddlewaretoken: {% csrf_token %},
         post_id = $('#post_id').val(),
         },
       });
      });
</script>
The HTML form:
<form onsubmit="return false">
 {% csrf_token %}
 <input type="text" name="post_id" value= {{post.pk}} hidden="hidden">
 <button type="submit" name="btnLike" class="btn btn-info">Like</button>
</form>
I know i'm doing something horribly wrong but I don't know what.
 
     
     
    