[英]Ajax 500 (Internal Server Error) Laravel Php
Laravel ajax 返回 500(内部服务器错误)。 你能告诉我有什么问题吗? Actually i'm using bootstrap-validator ( https://1000hz.github.io/bootstrap-validator/ ) and i need check email exist in database or not but when i fire ajax it gives 500 internal server error.
models.blade.php
{!! Form::open(['route' => 'customer.register', 'id' => 'registerForm', 'novalidate']) !!}
<input name="email" data-error="Oops!!, that email address is invalid" class="form-control input-lg flat" placeholder="{{ trans('theme.placeholder.your_email') }}" type="email" pattern=".*@\w{2,}\.\w{2,}" required data-emailexist data-emailexist-error="Email Already Exist" />
{!! Form::close() !!}
appjs.blade.php
<script type="text/javascript">
"use strict";
;(function($, window, document) {
$(document).ready(function(){
$.ajaxSetup ({
cache: false,
headers: {
'X-CSRF-TOKEN': "{{ csrf_token() }}"
}
});
var _token = $('input[name="_token"]').val();
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if(filter.test(email))
{
$.ajax({
url:"{{ route('email_available.check') }}",
method:"POST",
data:{email:email, _token:_token},
success:function(result)
{
if(result == 'unique')
{
return true;
}
else
{
return false;
}
}
});
}
</script>
用户身份验证.php
<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class UserAuthentication extends Controller
{
public function isRegisteredEmail(Request $request) {
if ($request->ajax()) {
$email = $request->get('email');
$data = DB::table("customers")
->where('email', $email)
->count();
if ($data > 0) {
echo 'not_unique';
} else {
echo 'unique';
}
}
}
}
web.php
Route::post('/email_available/check', 'Auth\UserAuthentication@isRegisteredEmail')->name('email_available.check');
错误
[2019-11-20 21:57:37] production.ERROR: Class App\Http\Controllers\UserAuthentication does not exist {"exception":"[object] (ReflectionException(code: -1): Class App\\Http\\Controllers\\UserAuthentication does not exist at H:\\dev\\wamp64\\www\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php:779)
[stacktrace]
#0 H:\\dev\\wamp64\\www\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(779): ReflectionClass->__construct('App\\\\Http\\\\Contro...')
#1 H:\\dev\\wamp64\\www\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(658): Illuminate\\Container\\Container->build('App\\\\Http\\\\Contro...')
#2 H:\\dev\\wamp64\\www\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(609): Illuminate\\Container\\Container->resolve('App\\\\Http\\\\Contro...', Array)
#3 H:\\dev\\wamp64\\www\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(759): Illuminate\\Container\\Container->make('App\\\\Http\\\\Contro...', Array)
#4 H:\\dev\\wamp64\\www\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(233): Illuminate\\Foundation\\Application->make('App\\\\Http\\\\Contro...')
用户身份验证文件位置图像用户身份验证文件位置
尝试composer dump-autoload
命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.