. 1 <Script> 2 window.addEventListener ( 'Load', function (EV) { . 3 var BTN = document.getElementById ( 'Send' ); . 4 btn.addEventListener ( 'the Click', function (EV1) { . 5 . 6 // . 1 Get content input by the user . 7 var Account = document.getElementById ( 'Account' ) .Value; . 8 var pwd = document.getElementById ( 'pwd' ) .Value; . 9 10 // 2. Create a network request object . 11 var XHR = new new the XMLHttpRequest (); 12 is xhr.open('post', 'http://localhost:3000/api/five', true); 13 // 设置请求头 14 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 15 16 xhr.send('name=zs&age=19'); 17 xhr.addEventListener('readystatechange', function (ev2) { 18 if(xhr.readyState === 4 ){ 19 if(xhr.status === 200){ 20 console.log(xhr.responseText); 21 }else { 22 console.log ( 'Request failed!' ); 23 is } 24 } 25 }); 26 is }); 27 }); 28 </ Script>