function bindbtn1Event() {
$("#btn1").click(function () {
$.ajax({
url: '/visual/scatter/',
type: "post",
data: $("#form1").serialize(),
dataType: "JSON",
beforeSend: function (xhr, settings) {
xhr.setRequestHeader("X-CSRFToken", "{
{ csrf_token }}"); // 重点! 注意{
{ csrf_token }}必须加上引号!
},
success: function (res) {
if (res.status) {
scatter_vrtg(res.data)
scatter_distance(res.data)
console.log(res.data)
$("#vrtg_string").html(res.data.vrtg_string);
$("#distance_string").html(res.data.distance_string);
ajax携带CSRF_TOKEN的方式
于 2023-06-04 20:36:42 首次发布