-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery_ajax
More file actions
38 lines (35 loc) · 1.06 KB
/
Copy pathjquery_ajax
File metadata and controls
38 lines (35 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//jquery 적용
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
//ajax
//get 방식
<script>
$.ajax({
url:'http://localhost/sum',
data: {
num1: $("#inputValue1").val(),
num2: $("#inputValue2").val()
},
success:function(response){
console.log(response);
$("#outputArea").html(response) //body에서 <span> 부분에 화면 뿌릴 때
// -> <span id="outputArea"> 부분 // .html()은 새로고침할 때마다 변경 됨
} // .append()는 내용이 추가되고 다 쌓여서 보여짐
});
</script>
//post 방식
<script>
$("#addBtn").click(function() { // 클릭할 때 실행되는 경우
$.ajax({
url: 'http://localhost/insert',
type: "POST",
data: {
title: $("#titleInput").val(),
content: $("#contentInput").val()
},
success: function(response) {
console.log(response);
$("#outputArea").html(response);
}
});
});
</script>