Answer the question
In order to leave comments, you need to log in
How to send an ajax variable and accept it on the page?
In general, I'm trying to figure out the lesson, I threw it like this
var CategoryVariable = "Text"
$.ajax({
url: "/resources/views/pages/AdminPanel/AddForm.blade.php",//по идее путь к странице
type: "POST",
dataType: "html",
data: {key: CategoryVariable},
error: function (){
alert('Ошибка. Данные не отправлены.');
},
})
$result
I know that they need to be accepted somehow, {{$result = json_encode(данные)}}
but I don’t understand exactly how, so far, tell me please)
Answer the question
In order to leave comments, you need to log in
AddForm.blade.php is the template file.
The URL is set in the /routes
folder
My advice, read the entire laravel documentation from start to finish, it is not long, but it will immediately become clear what it can do and where to look if anything. You can also find examples there.
The route refers to the controller, and the controller, in turn, receives the Request object in which the transmitted data is located, at the same time, the controller returns what needs to be received via this route.
Laravel - routing
What is MVC to understand what is going on there
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question