2
I’m starting with Laravel for a couple of weeks and automatically it’s raining with doubts.
I have a registration form with the following button below:
<button type="button" class="btn btn-primary" id="cadastrar-usuario">
<i class="fa fa-check"></i> Cadastrar Usuário
</button>
I have a Usuariocontroller.php that lists the Users, remembering that I am not using the table users of the same Language, I will use later.
I would like to call a Function from my controller.
My Controller is like this:
<?php namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
class UsuarioController extends Controller {
public function lista(){
$usuarios = DB::select("select * from usuarios");
return view('usuarios.listagem')->with('usuarios', $usuarios);
}
}
?>
How could I call him using ajax?
Don’t understand if it’s a question or an answer?
– Edu Mendonça
Just to complement the publication of the first reply, how it can perform the return in JSON
– Ismael SIlva
When it’s complimentary you can Edit your answer or by the Add-ons in the Comments... This will make your question/Answer clearer and readable.
– Edu Mendonça