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
Post a Comment