mercredi 20 novembre 2019

Ajax 500 (Internal Server Error) Laravel Php

{!! Form::open(['route' => 'customer.register', 'id' => 'registerForm', 'novalidate']) !!} {!! Form::close() !!}

                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:"",
                        method:"POST",
                        data:{email:email, _token:_token},
                        success:function(result)
                        {
                            if(result == 'unique')
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                    });
                }

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';
        }
    }
}

}

Route::post('/email_available/check', 'UserAuthentication@isRegisteredEmail')->name('email_available.check');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire