Answer the question
In order to leave comments, you need to log in
How to send ajax request in yii 2 and not get 400 (Bad Request) error?
Good day, I have a small problem.
I'm trying to send a POST request to the server via ajax in the yii 2 framework. I
created a separate controller for such requests. When trying to send any data to the controller:
url: "/ajax/message,
type: "POST",
data: "message=123123123"
POST http://site.ru/ajax/message 400 (Bad Request)
". url: "/ajax/message,
type: "POST"
Answer the question
In order to leave comments, you need to log in
Look at the rules of the router, maybe you have a different url there? For example, /ajax/message/
Try to manually enter this URL in the browser, /ajax/message, do you have such a page at all?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question