我正在做一个像票务系统的项目,有时它需要一些很长的答案,在答案区域中,我使用 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){}
});
}
}
});
我相信你得到了这个,因为这个<?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
注意此错误在您的代码中出现几次,因此请修改所有错误的块