我使用Codeigniter和jqgrid构建应用程序。出于安全原因,我最近启用了Codeigniter的内置CSRF保护,并使用jqgrid打破了一些内容。当jqgrid被实例化时,我已经能够传递csrf标记,以便加载所有数据(通过向postData添加csrf标记),但是现在随时编辑单元格时,我得到一个500错误,因为csrf标记不存在通过。每次编辑单元格时,我都可以通过查看发布数据来验证这一点。我阅读了editData是我想要的几个地方,但在那里添加令牌似乎没有通过编辑ajax请求传递它。有任何想法吗?通过单元格上的jqgrid传递csrf令牌
$("#cust_grid").jqGrid({
url:'/ajax/grid',
datatype: 'xml',
mtype: 'POST',
postData: {<?php echo $this->security->get_csrf_token_name().":'".$this->security->get_csrf_hash()."'"; ?>},
editData: {<?php echo $this->security->get_csrf_token_name().":'".$this->security->get_csrf_hash()."'"; ?>},
colNames:['Name1', 'Name2'],
colModel :[
{name:'name1', index:'name1', width:55, search: true},
{name:'name2', index:'name2', width:110, search: true},
],
pager: '#pager',
rowNum:25,
rowList:[10,25,50,100],
sortname: 'name1',
sortorder: 'asc',
viewrecords: true,
gridview: true,
caption: 'Customers',
height: 600,
width: 1200,
shrinkToFit: false,
altRows: true,
cellEdit: true,
cellsubmit: "remote",
cellurl: "/ajax/editCell",
},
{}
);
实际上,它看起来像我的问题很相似,这[一](HTTP ://stackoverflow.com/questions/10511521/codeigniter-with-jqgrid-use-csrf-token?rq = 1) 但那一个没有答案:( – Erreth