django - Ajax request type POST returning GET -



django - Ajax request type POST returning GET -

i'm trying create ajax post request send testimonial simple form django view. problem request returning instead of post.

this ajax:

<script> $(document).ready(function(){ $("form.testimonial-form").submit(function(e){ e.preventdefault(); var datastring = $(this).serialize(); $.ajax({ type: "post", url: "/testimonials", data: datastring, success: function(_data) { if (_data[0]){ $('.modal-text').css({display: "none"}); } else{ $('.unsuccess').css({display: "block"}); } } }); }); }); </script>

any thought doing wrong?

replace type method

method: 'post',

also may need send headers:

headers: { 'x-csrftoken': getcsrftoken() },

where getcsrftoken is:

function getcsrftoken() { homecoming $('input[name="csrfmiddlewaretoken"]').val(); }

ajax django post

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -