I am trying to send two variables in route through java script function. Javascript function:
function bookmark()
{
var url = '{{ route("save_bookmark",":b_id",":p_no") }}';
url = url.replace(':b_id', book);
url = url.replace(':p_no', count);
document.location.href = url;
}
book and count variables have been defined up in script.
When I pass only one variable through this code, it works fine but when I try to pass another variable it gives me error..
Missing required parameters for [Route: save_bookmark] [URI:save_bookmark/{b_id}/{p_no}].
My route:
Route::get("save_bookmark/{b_id}/{p_no}",'BookmarkController@create')->name('save_bookmark');
Do anyone know what's happening?
bladetemplate is going to render and execute the route before your javascript even replaces the variables.route('save_bookmark', ['b_id' => ':b_id', 'p_no' => ':p_no'])Source