I got an error when i want to validate an unique username using Boostrap FormValidation remote.
Below are the error that i received in the browser console:
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
Uncaught TypeError: b.success is not a function
Below are my code
$('#user_form').formValidation({
framework: 'bootstrap',
fields: {
username: {
validators: {
notEmpty: {
message: 'Username is required'
},
remote: {
message: 'This Username has already been taken',
url: '/check_unique',
data: {
type: 'username'
},
type: 'POST'
}
}
},
Web.php
Route::post('/check_unique', 'UserController@unique');
Controller
public function unique()
{
$user= User::where('username', Input::get('username'))->count();
if($user> 0) {
$isAvailable = FALSE;
} else {
$isAvailable = TRUE;
}
echo json_encode(
array(
'valid' => $isAvailable
));
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community