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

187
Views
¿Cómo puedo configurar la URL de la ruta desde AJAX?

WEB (ruta) :

 Route::get('/ajax-cat/edit/{id}', [App\Http\Controllers\AjaxCRUDController::class, 'categoryEdit'])->name('ajax.categoryEdit');

Código AJAX:

 $(document).ready(function () { $("#categoryBtn").click(function () { $("#catTable").show(); let html = ''; let i = 0; $.ajax({ url: '/ajax-cat', type: "GET", success: function (data) { for (const x of data) { html += `<tr> <th scope="row">${++i}</th> <td>${x.name}</td> <td><a href="{{route('ajax.categoryEdit',${x.id})}}" class="btn btn-danger">Edit</a></td> </tr>`; } $("#catTableBody").html(html); } }); }); });

Imagen del navegador:

ingrese la descripción de la imagen aquí

Pero quiero un enlace como este: 127.0.0.1:8000/ajax-cat/edit/2

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No puede fusionar sintaxis de diferentes idiomas como este.

{{ }} es de la Directiva Blade. https://laravel.com/docs/8.x/blade

 x.id

es una variable definida en su bloque de código javascript.

Lo que puedes hacer es:

 var url = '{{route("ajax.categoryEdit", ":id")}}'; url = url.replace(':id', x.id);

Luego puede concatenar su variable javascript dentro de su código html.

over 4 years ago · Santiago Trujillo Report
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!