更新时间:2022-01-18 21:25:12
请勿将POST请求用作GET请求.浏览器可能会限制URL的长度.
Don't make use of a POST request as a GET request. You're likely to run into browser limitations of how long an URL may be.
转
axios.post('/sendmessage/'+receive_id+'/'+message, {
进入
axios.post('/sendmessage', { id: receive_id, message: message })
然后在您的控制器中更改
Then in your controller change
public function store(Request $request,$receive_id, $message)
到
public function store(Request $request)
{
$receive_id = $request->input('id');
$message = $request->input('message');
要排除其他错误,请打开开发控制台.按F12. 单击网络选项卡,然后选择XHR日志记录.
To trouble shoot any other errors, open your development console. Press F12. Click on the network tab and select XHR logging.
发出请求.它将显示为错误500请求.单击文件名(红色镶边),然后单击响应.查看错误并进行诊断.
Make the request. it will show up as a error 500 request. click on the filename(red in chrome) and click on response. Look at the error and diagnose it.
Chrome中的示例
以您的情况
消息":"SQLSTATE [42S22]:找不到列:1054"字段列表中的未知列"updated_at"(SQL:插入消息中(receive_id,message,send_id,updated_at,created_at))值(3,测试,1,2018-08-08 13:00:54,2018-08-08 13:00:54))"
"message": "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: insert into messages` (receive_id, message, send_id, updated_at, created_at) values (3, test, 1, 2018-08-08 13:00:54, 2018-08-08 13:00:54))"
将$schema->timestamps()
添加到您的迁移文件中,或在Messages模型中设置属性public $timestamps = false;
Either add the $schema->timestamps()
to your migration file or set the property public $timestamps = false;
in your Messages model