this is my jquery ajax
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
type: 'post',
url: '/login',
data: {
'email' : $('#txtEmail').val(),
'password' : $('#txtPassword').val(),
},
dataType: 'json',
success: function(data) {
console.log(data);
}
});
i add meta in my html
<meta name="csrf-token" content="{{ csrf_token() }}">
my route like this
Route::post('/login', 'PenggunaController@login');
and my controller like this
use Illuminate\Http\Request;
class PenggunaController extends Controller
{
public function login(Request $request){
$email = $request->email;
echo $email;
}
}
please, can someone help me, what wrong with my code ?