【发布时间】:2016-12-01 05:59:11
【问题描述】:
我正在使用 codeigniter,我们已启用 CSRF 保护,
$config['csrf_protection'] = TRUE;
我们使用过:
`<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">`
在表单提交及其工作正常中,
但我的应用程序也使用 DataTables 通过 AJAX 获取服务器数据,
var handleDataTable = function () {
var table = $('#my_table').DataTable({
"ajax": {
"url" : baseURL + "user/core/data/"+report_id,
"dataType" : "json",
"type" : "POST", // ajax source
},
});
}
显然这将显示“The action you have requested is not allowed.”消息,
如何在 Ajax 检索数据中传递 csrf?
【问题讨论】:
标签: javascript jquery ajax codeigniter