Answer the question
In order to leave comments, you need to log in
How to send json to php without ajax?
Hello!
There is a form. It is filled in by the user and after clicking on the submit button, all data is sent to the post in the name.php file, which was specified in the action attribute. Generally standard behavior.
Question: How to submit along with JSON form?
What I tried:
JSON.stringify. As a result, we get a string instead of an object at the output. But how can I put it in a php file now?
What I was looking for:
There are a lot of ajax solutions on the Internet, but in my project, immediately after clicking on the "submit" button, the browser should go to the name.php file and there should be access to the JSON file (along with the data from the "name" fields of my forms).
What do I even want to do?
I made a basket on localStorage and linked the payment to YuKassa. I successfully implemented everything, but I can not transfer the goods from the "basket" localStorage. In the name.php file, a request is generated to Yukassu and then a redirect is carried out, so I thought that ajax didn’t seem to suit me ... although maybe I don’t know something.
Answer the question
In order to leave comments, you need to log in
What I tried:
JSON.stringify. As a result, we get a string instead of an object at the output. But how can I put it in a php file now?
$json = json_decode($_POST['json']);
After sending the request, you can then go to the desired page. Why not?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question