I've been trying hours to understand this and re-check StackOverflow's answer. Tried copy pasting too, didn't work.
var app = new Vue({
el: '#app',
data: {
jobtype_select: '',
jobtype_list: [{
id_JobType: 'JTY0001',
name_JobType: 'Survey'
},
{
id_JobType: 'JTY0002',
name_JobType: 'Research'
},
{
id_JobType: 'JTY0003',
name_JobType: 'Maintenance'
}
],
woFormABCD: '',
totallyRandom: 'Hello Heiayo'
},
methods: {
recordTESTWo() {
var form = new FormData();
form.append('test', this.totallyRandom);
axios.post('action.php',
form
)
.then(function(response) {
alert('Success!');
console.log(response);
})
.catch(function(error) {
console.log(error);
});
}
}
});
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<div id='app'>
<form method="post" action="action.php" @submit.capture='recordTESTWo'>
<div class="">
<label for="jobtype_id" class="control-label required"><strong>Choose Job Type</strong></label>
<div v-for='jobtype in jobtype_list'>
<label class="">
<input type="radio"
id= 'jobtype_id'
v-model= 'jobtype_select'
:value="jobtype.id_JobType"
name='jobtype_select'
>
{{jobtype.name_JobType}}
</label>
</div>
<p> This is : {{jobtype_select}}</p>
</div>
<div>
<button>Submit</button>
</div>
</form>
</div>
What I wanted to do was to try to pass totallyRandom value to the next page. Which is action.php.
<?php
session_start();
//$data = json_decode(file_get_contents("php://input"), TRUE);
printf("This is GET: \r\n");
var_dump($_GET);
printf("This is POST: \n");
var_dump($_POST);
?>
What I expect to see,
the variable of totallyRandom being passed to action.php so I can use it on action.php page.
What I see, Also, when I go to action.php, and do var_dump it returns NULL. The radio button passed, but that's not using Axios. More details can be asked,

methods, notmethod. Second, when you useFormData, axios will post aapplication/x-www-form-urlencodedencoded request body so your PHP should use$_POST['test']and notphp://input. Voting to close as a typo