S
S
Sergeyjed2019-03-25 21:50:16
Vue.js
Sergeyjed, 2019-03-25 21:50:16

Pass vue.js form data in json key/value format to php handler?

I'm doing something wrong https://codepen.io/serg-style/pen/bZZyeb
In the handler, for now, I'm just displaying

<?php
     print($jsonData);
?>

Empty

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
wagoodoogoo, 2019-03-25
@Sergeyjed

<?php
$postData = file_get_contents('php://input');
$data = json_decode($postData);
print $data->name;

M
monochromer, 2019-03-25
@monochromer

If you send in `multipart/form-data` format

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' }}
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question