当用户点击下拉菜单并做出不同的选择,然后更改名为defaultCharacterID的会话密钥时,会运行此脚本,然后我会计算出何时在控制台中显示发布请求它说:“您所请求的操作是不允许的下拉式jQuery没有执行
PHP:
public function changeDefaultCharacter()
{
if ($this->input->post('defaultCharacterID'))
{
$this->session->set_userdata($this->input->post('defaultCharacterID'));
}
}
的jQuery:
$(document).ready(function() {
$('#charactersDrop').change(function() {
// POST the changed value to a method in a controller that can accept
// a parameter and that'll set the session variable for you
$.post('dashboard/changeDefaultCharacter',
{ defaultCharacterID: this.value },
'html'
);
});
});
编辑:
$(document).ready(function() {
$('#charactersDrop').change(function() {
// POST the changed value to a method in a controller that can accept
// a parameter and that'll set the session variable for you
$.post('dashboard/changeDefaultCharacter',
{ defaultRosterListID: this.value },
<?php echo $this->security->get_csrf_token_name(). ':'.
$this->security->get_csrf_hash(); ?>
}
,
'html'
});
});
你使用什么版本的CI的? – safarov 2012-04-09 13:31:58
版本2.1我相信 – 2012-04-09 13:35:39
检查配置文件的'csrf_protection'值,确保它的'false' – safarov 2012-04-09 13:36:25