Answer the question
In order to leave comments, you need to log in
How to implement data transfer from js to action yii2?
Good day!
There is a task: to implement some kind of metrics / analytics of site visitors.
As done now:
REST api
When index is accessed, actionCreate is executed, we create a new object of the Visitor type, when creating it, we fill in its properties ip, user agent, etc., then we send it all to the database.
As you want to do:
when loading, when loading the page, some js file receives client data (ip, user agent, etc.) and passes them to actionCreate (the name of the action is conditional), which in turn sends the received data to the database.
What's the question:
how to implement the transfer of the necessary data correctly, and in general, will the working scheme turn out (provided that the client has js enabled of course)? Or is it worth further developing it all in php?
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