标签:asc article ken form表单 dig success tips url for
data 里加 csrfmiddlewaretoken:$("[name=‘csrfmiddlewaretoken‘]").val(),
还要再 form表单里加{% csrf_token %} 或者 如下 ,反正一定要加
<div class="buryit action">
<span class="burynum" id="bury_count">{{ article.down_count }}</span>
</div>
<div class="clear"></div>
<div class="diggword" id="digg_tips">
</div>
</div>
{% csrf_token %}
<script>
$("#div_digg .action").on("click", function () {
let is_up=$(this).hasClass("diggit");
let article_id="{{ article.pk }}";
$.ajax({
url:"/blog/up_down/",
type:"post",
data:{
csrfmiddlewaretoken:$("[name=‘csrfmiddlewaretoken‘]").val(),
},
success:function (data) {
console.log(data);
}
})
})
</script>
{% endblock %}
标签:asc article ken form表单 dig success tips url for
原文地址:https://www.cnblogs.com/deskyaki/p/10358518.html