Answer the question
In order to leave comments, you need to log in
How to get a variable in a template?
Good day everyone
I'm trying to make a quick view of the product in a modal window like on this site https://likadress.ru/.
I wrote a script for this
$(".element-view").on("click", function (e) {
let id = $(this).attr("id_product");
e.preventDefault();
$.ajax({
url: '/products/'+id,
type: 'POST',
dataType:"json",
success(response){
$(".modal_details").addClass("show-modal");
},
error(){
console.log("ERROR");
}
});
});
public function modal($id)
{
$product = Product::find($id);
return response()->json($product);
}
{id: 53, title: "Брюки LB 52-071", alias: "bruki-LB-52-071-", meta_title: "Брюки LB 52-071", meta_description: "", …}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question