【发布时间】:2020-08-17 12:22:36
【问题描述】:
我不明白,我将axios 请求发送到insert.php,但由于某种原因它没有找到它。变量 note_text = null。我知道这是因为我不知道我要发送哪个变量 2 参数。
我以为有一个变量$ _POST['note_text]。
我的 axios 调用:
let app = new Vue({
el: '#app',
data: {
newNote: '',
info: {
}
},
mounted: function() {
},
methods: {
addNewNote: function() {
alert('work');
axios.post('insert.php', {
note_text: this.newNote
})
.then(response => (this.info = response));
}
}
});
我的 php 调用:
$connect = mysqli_connect('127.0.0.1', 'root', '', 'axios');
$sql = "INSERT INTO todo (name) VALUES ('" . $_POST['note_text'] ."')";
$query = mysqli_query($connect, $sql);
【问题讨论】:
标签: javascript php vue.js axios backend