Answer the question
In order to leave comments, you need to log in
How to accept variable in laravel controller?
How to pass a variable to the controller via js in laravel and accept it there?
In Codeigniter I did this:
function add(obj) {
var id = obj.id;
$.ajax({
url: "<?php echo base_url(); ?>" + "index.php/main/add_to_card",
type: "POST",
data: {"id": id},
cache: false,
success: function (response) {
window.location.reload();
}
});
}
$id= trim($_POST['id']);
Answer the question
In order to leave comments, you need to log in
function add(obj) {
var id = obj.id;
$.ajax({
url: document.location.origin+ "/main/add_to_card",
type: "POST",
data: {"id": id},
cache: false,
success: function (response) {
window.location.reload();
}
});
}
$id = request()->input('id')
Replace the url from the example with
A. Further "how", "what" and "where" depend on your tasks and needs, and are located on the pages of the documentation you hate so much with blood and love: https://laravel.com/docs/5.7 /blade
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question