Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
Ajax jQuery no redirige a la url con Laravel

Soy nuevo en Ajax, pero pude crear un formulario donde escribo datos -> enviar y el controlador hace su trabajo. Mi problema es que quería hacer un botón de borrar para los registros, pero no funciona, solo recarga la página, la ruta está bien, la alerta funciona bien y el token también.

Aquí está el código:

La ruta

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

El botón

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

La parte js:

 <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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!