To transfer data form vue.js json key/value to the php handler?

Something not so do https://codepen.io/serg-style/pen/bZZyeb

In the handler, until just output the
<?php
print($jsonData);
?>


Empty
March 19th 20 at 08:33
2 answers
March 19th 20 at 08:35
Solution
<?php
$postData = file_get_contents('php://input');
$data = json_decode($postData);
print $data->name;
March 19th 20 at 08:37
If you send in the format `multipart/form-data`
const formData = new FormData(this.$refs.form);

axios({
 method: 'post',
 url: 'http://appvue.pickstyle.ru/static/lib/phpfile.php',
 data: formData,
 config: { headers: {'Content-Type': 'multipart/form-data' }}
})
Did not work, the source code with the form https://yadi.sk/d/SmCI5RQN80rG7Q - Michelle commented on March 19th 20 at 08:40
@Michelle, the source is not the same as in the question. Again - if sent as multipart/form-data
1. To put a ref-a reference to the form
2. To collect data using FormData:
const formData = new FormData(this.$refs.form);
3. Send
axios({
 method: 'post',
 url: 'send.php',
 data: formData,
 config: { headers: {'Content-Type': 'multipart/form-data' }}
})

4. Processing
$name = $_POST["name"];

If sent as json, the response in the neighborhood. - effie.Wehner55 commented on March 19th 20 at 08:43

Find more questions by tags Vue.js