问题
I'm try to pass data to a php script via axios but I am not having any sucess My scripts are below:
AXIOS SCRIPT
var config = {
headers: {
'X-Requested-With': 'XMLHttpRequest',
}
};
new Vue({
el:'#app',
data:{
email:'',
access:''
},
methods:{
signin:function(){
console.log(this.email + ' ' + this.access);
let url = '../App/testConnection.php';
axios.post(url,{email:this.email, code:this.access}, config)
.then((response) =>{
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
//console.log(this.email + ' ' + this.access);
//alert(this.email);
}
} });
PHP SCRIPT
$data = $_POST;
var_dump($data);
回答1:
Your url is incorrect. Try another url which is
let url = 'domainname.com/App/testConnection.php';
Or
let url = 'localhost/App/testConnection.php';
If you test localy
来源:https://stackoverflow.com/questions/49973312/passing-data-to-php-script-via-axios-ajax-post