form.html
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <form> <span class="login100-form-title p-b-26"> Welcome </span> <div class="wrap-input100 validate-input" data-validate="Valid email is: a@b.c"> <input class="input100" type="text" id="email" value="222@222.com"> </div> <div class="wrap-input100 validate-input" data-validate="Enter password"> <span class="btn-show-pass"> <i class="zmdi zmdi-eye"></i> </span> <input class="input100" type="password" id="pass" value="@@@@@@@@@@"> </div> <div class="container-login100-form-btn"> <div class="wrap-login100-form-btn"> <div class="login100-form-bgbtn"> </div> <button class="login100-form-btn" onclick="login_click();"> Login </button> </div> </div> </form> <script> function login_click() { var email = $("#email").val(); var pass = $("#pass").val(); axios({ method: 'post', url: '/login_auth', data: { email: email, pass: pass } }).then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }); } </script> |
jquery와 Axios를 활용한 form 값 전달
login_auth.js
router.post('/login_auth',async (req,res, bodyParser) => { var input_id = req.body.email; var input_pw = req.body.pass; console.log(' ',input_id); console.log(' ',input_pw); res.json({ 'result' : 'true' }); }) |
data에 response값 전달
'nodejs' 카테고리의 다른 글
nodejs so파일 (0) | 2021.09.10 |
---|---|
MongoError: Cannot use a session that has ended (0) | 2021.07.20 |
nodejs 버전 업데이트 하기 (0) | 2021.07.15 |
nodemon 설정 방법 (0) | 2020.12.09 |
web3.js 비동기 nodejs 함수 비교 (0) | 2020.11.24 |