[英]CKeditor textarea data only submit first into database laravel 5.5
Im having a problem where when I submit the form , my data for ckeditor only insert one line to database . 我在提交表单时遇到问题,我的ckeditor数据仅向数据库插入一行。 When I try to vardump the variable of data request it show all the data from line 1 to line 3 . 当我尝试对data request变量进行vardump时,它将显示从第1行到第3行的所有数据。
Data vardump 数据仓库
Data Insert Into Database 数据插入数据库
Here Is my code for store the data into database . 这是我的代码,用于将数据存储到数据库中。
$aktiviti->title = $request->input('aktivitiName');
$aktiviti->content = $request->input('text');
$aktiviti->image_url = $url;
$aktiviti->updated_by = $user_name;
$result = $aktiviti->save();
Here is my ajax to submit the form 这是我的ajax提交表格
$('#formaktiviti').submit(function(e){
e.preventDefault();
var value = CKEDITOR.instances['ckeditor'].getData();
console.log(value);
var myform = document.getElementById("formaktiviti");
var fd = new FormData(myform );
fd.append('text',value);
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url:'http://localhost:8888/KoBPM/public/postAktiviti',
method: 'POST',
data:fd,
contentType: false,
cache: false,
processData: false,
success:function(data){
var response = JSON.parse(data);
if(response.status == true){
alert('success')
}else{
alert('failed');
}
}
});
});
So what cause the data not complete when submit into database ? 那么,什么原因导致在提交数据库时数据不完整?
u var_dump() the data and it seems right, in my first sight, ur database field may be not suitable or long enough , u can use longtext to save the field if it can solve ur problem if not, remove ur Ajax to see the data u saved. u var_dump()数据,这似乎是正确的,在我看来,您的数据库字段可能不合适或足够长,如果可以解决您的问题,则可以使用longtext保存该字段,否则,请删除ur Ajax来查看您保存的数据。 best wishes. 最好的祝愿。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.