How to Pass a Variable To Route in JavaScript in Laravel
The Correct Syntax for Passing a Variable to Laravel Route in JavaScript.
This is a short snippet to pass a variable on route in javascript.
var url = '{{ route("admin.stocks.edit", ":id") }}'; url = url.replace(':id', stock.id); $('.stocks_list').append('<li><a href="'+url+'">' + stock.symbol + ' </a></li>');