Answer the question
In order to leave comments, you need to log in
how to pass url to javascript?
There is a route
Route::get('/materials/{material_id}/link/{link_id}', [MaterialController::class, 'showLink']);
public function showLink()
{
return response()->json([
"link" => Link::find(15)
]);
}
$('.edit-link').click(function(){
var date = $(this).attr("data-id");
//var date = $(this).attr('value');
$.ajax({
url: '/materials/' + 4 +'/link/' + 16,
data: { date: date},
type: "GET",
success: function(data){
console.log(data);
console.log(data['link']['name']);
$('#floatingModalSignature').val(data['link']['name']);
$('#floatingModalLink').val(data['link']['name']);
}
});
});
Answer the question
In order to leave comments, you need to log in
Laravel has a route helper. To use it, you need to give the route a name. https://laravel.com/docs/8.x/helpers#method-route Have a look.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question