前台就是一个表单,这里是用的bootstrop的
php只简单验证了一个邮箱
public function postMassage(Request $Request) { $email = $Request->email; $messages = $this->article_messages->where('email',$email)->first(); if (!empty($messages)) { return response()->json(['status' => 'ok','code' => 400,'message' => '该邮箱已存在!换一个吧!',]); } }
ajax的请求POst
最终: