var url = '{{ route("admin.edit_school", ":slug") }}';
url = url.replace(':slug', slug);
window.location.href=url;
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want to add a value to my named routing from javascript
This is my route
{{ route('admin.edit_school', ['slug' => $variable_here]) }}
This is what I tried but it's not working
var slug = $(this).data('row-abbreviation');
var url = "{{ route('admin.edit_school', ['slug' => '"+slug "']) }}";
window.location.href=url;
Please how can I achieve this..
var url = '{{ route("admin.edit_school", ":slug") }}';
url = url.replace(':slug', slug);
window.location.href=url;
Please or to participate in this conversation.