'how can i set url of route from AJAX
WEB (route) :
Route::get('/ajax-cat/edit/{id}', [App\Http\Controllers\AjaxCRUDController::class, 'categoryEdit'])->name('ajax.categoryEdit');
AJAX Code:
$(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);
}
});
});
});
Picture from Browser:
But I want Link like this: 127.0.0.1:8000/ajax-cat/edit/2
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

