<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Axios POST Request</title>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
<button id="postButton">Send POST Request</button>
<script>
document
.getElementById('postButton')
.addEventListener('click', function () {
axios
.post('', {
password: '',
username: ''
})
.then(function (response) {
console.log(response.data)
alert(`successful==>>【${response.data.data}】`)
})
.catch(function (error) {
console.error('There was an error!', error)
alert('POST request failed!')
})
})
</script>
</body>
</html>
09-26
2017
08-06
2610
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交