UNPKG

855 BHTMLView Raw
1<!DOCTYPE html>
2<html>
3<head>
4 <style>
5 #wmsPayload{
6 resize: none;
7 overflow: auto;
8 width: 500px;
9 height: 500px;
10 }
11 #send{
12 vertical-align: top;
13 }
14 </style>
15</head>
16 <body>
17 <textarea id="wmsPayload">{
18 "msg":"Text"
19}</textarea>
20 <button id="send" onClick="cal()">Send</button>
21 <script>
22 function cal() {
23 var xhttp = new XMLHttpRequest();
24
25 xhttp.onreadystatechange = function() {
26 if (this.readyState == 4 && this.status == 200) {
27 // Typical action to be performed when the document is ready:
28 }
29 };
30 xhttp.open('POST', '/wmsmockapi', true);
31 xhttp.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
32 var a = document.getElementById('wmsPayload').value;
33 var obj = JSON.parse(a);
34 console.log(obj);
35 xhttp.send(JSON.stringify(obj));
36}
37</script>
38 </body>
39</htm>