我尝试使用欧芹远程验证注册表单的电子邮件和用户名。我总是收到以下信息:
public/checkUserName?username=tester 405 (Method Not Allowed)
所以这是我的代码:
输入:
<input data-parsley-remote="{{ route('checkUserName') }}" data-parsley-remote-message="Der Username ist bereits vergeben!" data-parsley-remote-options='{ "type": "POST", "dataType": "jsonp", "data": {_token: CSRF_TOKEN, "UserName": "username" } }'
路线:
Route::post('/checkUserName', [
'uses' => 'UserController@checkUserName',
'as' => 'checkUserName'
]);
用户控制器:
public function checkUserName(Request $request)
{
if(user::where('UserName','=',$request->input('UserName'))->exists()){
return response::json('exists', 404);
}else{
return response::json('not exists', 200);
}
}