mirror of
https://github.com/axios/axios.git
synced 2026-04-13 02:51:56 +08:00
* README.md COOKBOOK.md: minor fixes * simplify language * ECOSYSTEM: create a few categories * Examples: log port listening to * upgrade bootstrap 3 -> 4 in examples bootstrap 4 is slightly smaller then 3.2.0 so it should also help load examples faster * categorize 0.19 items a little differently surface user/consumer changes first
41 lines
1.2 KiB
HTML
41 lines
1.2 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>axios - post example</title>
|
|
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"/>
|
|
</head>
|
|
<body class="container">
|
|
<h1>axios.post</h1>
|
|
|
|
<form role="form" class="form" onsubmit="return false;">
|
|
<div class="form-group">
|
|
<label for="data">JSON</label>
|
|
<textarea id="data" class="form-control" rows="5"></textarea>
|
|
</div>
|
|
<button id="post" type="button" class="btn btn-primary">POST</button>
|
|
</form>
|
|
|
|
<div id="output" class="container"></div>
|
|
|
|
<script src="/axios.min.js"></script>
|
|
<script>
|
|
(function () {
|
|
var output = document.getElementById('output');
|
|
document.getElementById('post').onclick = function () {
|
|
var data = document.getElementById('data').value;
|
|
|
|
axios.post('/post/server', JSON.parse(data))
|
|
.then(function (res) {
|
|
output.className = 'container';
|
|
output.innerHTML = res.data;
|
|
})
|
|
.catch(function (err) {
|
|
output.className = 'container text-danger';
|
|
output.innerHTML = err.message;
|
|
});
|
|
};
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|