第一种
<script>
$(".eq").on("click",function () {
$.ajax({
url:"/eq/",
type:"POST",
data:{
csrfmiddlewaretoken:{{ csrf_token }},
a:$(".a").val(),
b:$(".b").val()
},
success:function (data) {
$(".c").html(data);
}
})
})
</script>
第二种
<script>
$(".eq").on("click",function () {
$.ajax({
url:"/eq/",
type:"POST",
data:{
csrfmiddlewaretoken:$("input:first").val(),
a:$(".a").val(),
b:$(".b").val()
},
success:function (data) {
$(".c").html(data);
}
})
})
</script>
第三种
jquery.cookie.js下载地址:https://plugins.jquery.com/cookie/
<script src="/static/jquery.cookie.js"></script>
<script>
$("#btn").on("click",function () {
$.ajax({
url:"/lianxi/",
type:"POST",
headers:{"X-CSRFToken":$.cookie('csrftoken')},
data:$("#f1").serialize()
})
})
</script>