[JS + jquery] Ajax๋ก ๊ฐ๋จํ ๋ก๊ทธ์ธ ๋ง๋ค๊ธฐ
2021. 11. 2. 13:49ใHTML + CSS + JS/JS ์๋ฐ์คํฌ๋ฆฝํธ
728x90
๋ก๊ทธ์ธ ๋ฒํผ์ ๋๋ฅด๋ฉด
1. php
2. html
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title> Ajax </title>
<link rel="stylesheet" href="css/login.css" />
<script src="js/jquery.js"></script>
<script>
$(function() {
var $frm = $(".login_f");
$frm.on("submit", function(e) {
e.preventDefault();
var myData = $frm.serialize();
$.ajax({
type: "POST",
url: $frm.attr("action"),
data: myData,
success:function(res) {
if(res) {
var jsonData = JSON.parse(res);
var message = jsonData.user_name +
"( " + jsonData.user_id + " )"
+ "๋ ๋ฐ๊ฐ์ต๋๋ค";
$(".login_wrap").html(message);
}
}
});
});
});
</script>
</head>
<body>
<div class="login_wrap">
<h1>๋ก๊ทธ์ธ</h1>
<form class="login_f" method='post' action='member_login_ok.php'>
<p>
<label for="user_id">์์ด๋</label>
<input type="text" name="user_id" id="user_id" value="korean" />
</p>
<p>
<label for="user_pw">๋น๋ฐ๋ฒํธ</label>
<input type="password" name="user_pw" id="user_pw" value="12345" />
</p>
<p><input type="submit" value="๋ก๊ทธ์ธ" class="login_btn" /></p>
</form>
</div>
</body>
</html>
728x90
'HTML + CSS + JS > JS ์๋ฐ์คํฌ๋ฆฝํธ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JS + jquery] ์ ์ด์ฟผ๋ฆฌ UI ํ๋ฌ๊ทธ์ธ draggable(), Datepicker() (0) | 2021.11.03 |
---|---|
[JS + jquery] ์ ์ด์ฟผ๋ฆฌ ํ๋ฌ๊ทธ์ธ (0) | 2021.11.03 |
[JS + jquery] RSS ์ฐ๋ํ๊ธฐ (0) | 2021.11.02 |
[JS + jquery] Ajax ๊ด๋ จ ๋ฉ์๋์ Ajax๋ก JSON ๋ฐ์ดํฐ ๋ฐ์ธ๋ฉ, XML ๋ฐ์ดํฐ ๋ฐ์ธ๋ฉ (0) | 2021.11.02 |
[JS + jquery] Ajax (0) | 2021.11.02 |