我正在开发一个类似于票务系统的项目,有时它需要一些很长的答案,在答案区域中,我使用CKEDITOR,而键入的代理会使用Json GET自动将更改保存到数据库中,但是有些长答案不起作用,将显示以下错误:
Request-URI Too Long
The requested URL's length exceeds the capacity limit for this server.
Additionally, a 414 Request-URI Too Long error was encountered while trying to use an ErrorDocument to handle the request.
我发现这是由于使用GET引起的,建议我将其更改为POST,因为我没有该错误,现在我禁止使用403
这是json代码
CKEDITOR.replace('consulta-body', {
height: '300',
on: {
change: function( evt ) {
for ( instance in CKEDITOR.instances ){
CKEDITOR.instances[instance].updateElement();
}
var BodyText = $('#consulta-body').val();
console.log( BodyText );
var FormData = {};
FormData['update'] = '1';
FormData['id'] = <? echo $this->uri->segment(3);?>;
FormData['name'] = 'previo';
FormData['val'] = BodyText;
$.ajax({
dataType: 'json',
type: 'POST',
data: FormData,
url: '<?echo base_url('consultas/ver/1212');?>',
beforeSend: function(){},
success: function(Response){}
});
}
}
});
预先感谢
编辑: 尝试过这一点,在控制台上没有任何错误,但没有保存到数据库
CKEDITOR.replace('consulta-body', {
height: '300',
on: {
change: function( evt ) {
for ( instance in CKEDITOR.instances ){
CKEDITOR.instances[instance].updateElement();
}
var BodyText = $('#consulta-body').val();
console.log( BodyText );
var FormData = {};
FormData['<?php echo $this->security->get_csrf_token_name(); ?>']
= '<?php echo $this->security->get_csrf_hash(); ?>';
FormData['update'] = '1';
FormData['id'] = <? echo $this->uri->segment(3);?>;
FormData['name'] = 'previo';
FormData['val'] = BodyText;
$.ajax({
dataType: 'json',
type: 'POST',
data: FormData,
url: '<?echo base_url('consultas/ver/1212');?>',
beforeSend: function(){},
success: function(Response){}
});
}
}
});
答案 0 :(得分:0)
我相信您会得到这个,因为此<?echo base_url('consultas/ver/1212');?>
会产生错误。
您可以这样写:
<?php echo base_url('consultas/ver/1212'); ?>
或这样:
<?= base_url('consultas/ver/1212'); ?>
请参阅: https://www.codeigniter.com/user_guide/general/alternative_php.html
请注意此错误在您的代码中出现过几次,因此请修改所有错误的块