Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
Ajax jQuery doesn't redirect to the url with Laravel

I'm new to Ajax, but I was able to make a form where I write data -> submit and the controller does it's job. My problem is that I wanted to make a delete button for the records, but it doesn't work, just reloads the page, the route is fine, the alert works fine and the token is fine too.

Here is the code:

The route

Route::post('/delete/{testTaker}', [TestTakerController::class, 'delete']);

The button

<form id="delete">
    {{ csrf_field() }}
       <button class="deletett" data-id="{{ $testTaker->testTaker }}">delete</button>
</form>

The js part:

<script src="http://code.jquery.com/jquery-3.3.1.min.js"
            integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
            crossorigin="anonymous">
</script>
<script>
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
            }
        });
            $(".deletett").click(function(){
                var testTaker = $(this).data("id");
                alert(testTaker);
                jQuery.ajax({
                    url: "/delete/" + testTaker,
                    method: 'post',
                    data: {
                        name: testTaker
                    },
                    success: function(result){
                        jQuery('.alert').show();
                        jQuery('.alert').html(result.success);
                    }});
        });

    </script>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda