#30641: Update docs for using CSRF with Ajax
-------------------------------------+-------------------------------------
               Reporter:  JeroenvO   |          Owner:  nobody
                   Type:             |         Status:  new
  Cleanup/optimization               |
              Component:  CSRF       |        Version:  2.2
               Severity:  Normal     |       Keywords:  csrf token jquery
           Triage Stage:             |  context templatetag ajax
  Unreviewed                         |      Has patch:  0
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Docs state: (https://docs.djangoproject.com/en/2.2/ref/csrf/)
 In order to get CSRF token in Javascript, for instance for an AJAX
 request.

 {{{
 {% csrf_token %}
 <script type="text/javascript">
 var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
 </script>
 }}}

 but since {{ csrf_token }} is available in the context, a much cleaner
 version would be:


 {{{
 <script type="text/javascript">
 // using jQuery
 var csrftoken = '{{ csrf_token }}';
 </script>
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30641>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.8f5415646e85f857a4329c1ffe1957b8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to