当用户单击下拉菜单并进行不同的选择然后更改名为 defaultCharacterID 的会话密钥时,将运行此脚本,我很想弄清楚它何时在控制台中显示“您拥有的操作”的发布请求不允许请求。
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'
});
});