12345678910111213141516171819202122232425262728293031 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>demo</title>
- </head>
- <body>
- <input type="email" placeholder="邮箱" name="email" id="emailer">
- <input type="text" placeholder="信息" name="message" id="messager">
- <input type="button" value="发送" onclick="loadDoc()">
- <div id="State"></div>
- </body>
- <script>
- function loadDoc() {
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- document.querySelectorAll('#State')[0].innerHTML = '发送成功'
- }else if (this.status == 201) {
- document.querySelectorAll('#State')[0].innerHTML = '服务器出错'
- }
- };
- xhttp.open("POST", "http://short.1473.cn/postemail", true);
- xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- xhttp.withCredentials = true;
- xhttp.send(`useremail=${document.querySelectorAll('#emailer')[0].value}&usermessage=${document.querySelectorAll('#messager')[0].value}`);
- }
- </script>
- </html>
|