首页 > 解决方案 > 我在下面的代码中得到一个 CSRF Exceptionin html 页面

问题描述

function startJob(id) {
    jQuery.get(servletURL, {
        ACTION: "START",
        ID: id
    }, function(jsonObject) {
        printAjaxResponse(jsonObject);
    }, "json");
}

标签: jqueryhtmlajax

解决方案


function startJob(id) {
  jQuery.get(servletURL, {
    ACTION: "START",
      ID: id
   },{
   headers:{
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}, function(jsonObject) {
      printAjaxResponse(jsonObject);
   }, "json");
}

推荐阅读