0

I have included {% csrf_token %} in my HTML form(which includes textboxes and some checkboxes) in Django still I get Forbidden (CSRF token missing or incorrect.) error because of processData:false in AJAX. If I try removing processData:false from AJAX the form only keeps loading without any result. In browser console I get the following error:Uncaught TypeError: Illegal invocation .

How do I fix this?

Leman Kirme
  • 530
  • 1
  • 5
  • 19
  • Does this answer your question? [Django CSRF check failing with an Ajax POST request](https://stackoverflow.com/questions/5100539/django-csrf-check-failing-with-an-ajax-post-request) – yedpodtrzitko Sep 22 '20 at 03:24
  • can you send the code of your HTML form – samir Sep 22 '20 at 06:28
  • @samir https://drive.google.com/file/d/1UFw49J3nUfOQtXyAvce6gYjFvOFon8v1/view?usp=sharing – Leman Kirme Sep 22 '20 at 07:43
  • @LemanKirme please read the question and answer I linked in the comment above. CSRF token isnt send with ajax automatically, you have to add it manually. As explained in the question linked above. Read it. – yedpodtrzitko Sep 22 '20 at 07:51
  • @yedpodtrzitko I didn't understand that answer fully as I am a beginner in JavaScript n all...may you please tell me how exactly should I add automatically...for reference you can check my html code for which I gave the link above – Leman Kirme Sep 22 '20 at 09:49

1 Answers1

-2

Place the decorator @csrf_exempt in the view you are calling.

Jorge Luis
  • 902
  • 12
  • 25