jquery - 我在下面的代码中得到一个 CSRF Exceptionin html 页面
问题描述
function startJob(id) {
jQuery.get(servletURL, {
ACTION: "START",
ID: id
}, function(jsonObject) {
printAjaxResponse(jsonObject);
}, "json");
}
解决方案
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");
}
推荐阅读
- xaml - XAML 构建的本地 TFS 到 VSTS 迁移
- javascript - REACT Todo-List:如何检查数组中是否已存在项目
- apache-kafka - Kafka 如何在内部对分区内的消息进行排序?它是否按照从生产者那里收到的内容存储它们?
- wordpress - 如何通过rest api使用html添加WooCommerce产品内容
- java - 经常更新用户数据
- r - `[.data.frame`(num.response,x == y)中的R mlr surv.ranger错误:选择了未定义的列
- javascript - 在代码和框网站中使用 onclick 时出现 ReferenceError
- batch-file - 如何在批处理编程中从属性文件中读取值
- reactjs - 如何生成 GraphQL 文档资源管理器
- django - 在 django-cron 中的特定日期和时间发送请求