add.jsp 수정

This commit is contained in:
daniel LEE 2023-11-02 10:40:13 +09:00
parent d71663e0d6
commit 1efd16f1ac
2 changed files with 22 additions and 39 deletions

View File

@ -48,15 +48,6 @@ public class JSPController {
return "add"; return "add";
} }
@GetMapping("/addItem")
public void addItem(HttpServletRequest request) {
String id = request.getParameter("id");
System.out.println( id );
}
@GetMapping("/index.do") @GetMapping("/index.do")
public String index(Model model) { public String index(Model model) {

View File

@ -8,33 +8,23 @@
<title>Insert title here</title> <title>Insert title here</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" ></script> <!--jQuery 불러오기--> <script src="http://code.jquery.com/jquery-3.4.1.min.js"></script>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$("#buttonSubmit").on('click',function(){ // 제출 버튼 이벤트 지정 $('#add').on('click', function(){
$.ajax({ $.ajax({
url: "https://api.leejk0523.com/profile/user/10", // 목적지 url: "/user/10",
async: true, type: "POST",
type: "POST", // HTTP Method data: $('#theForm').serialize(),
data: $("#theForm").serialize(), // 전송 데이터 success: function(data){
dataType: "text", // 전송 데이터 형식 //location.href="listUser.do";
success: function(result, status){ // 성공 시 실행 alert("신규등록 OK");
console.log("성공'); },
console.log(data.status); error: function(error){ alert(error); }
alert(result); });
});
//$("#result_name").html(res.name); });
//$("#result_ph_number").html(res.ph_number); </script>
//$("#result_address").html(res.address);
},
error:function(equest, status, error) { //실패 시 실행
console.log("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
alert("실패 원인 : " + error);
}
});
});
});
</script>
</head> </head>
<body> <body>
@ -48,9 +38,11 @@
<form id="theForm" method="post" enctype=”multipart/form-data”> <form id="theForm" method="post" enctype=”multipart/form-data”>
<table> <table>
<tr> <tr>
<td>ID <input type="text" name="id" size="50"/><br></td> <td>Name <input type="text" id="name" name="name" value="50"/><br></td>
<td><input type="file" multiple="multiple" name="fileob"></td> <td>Phone <input type="text" id="phone" name="phone" value="50"/><br></td>
<td><input id="buttonSubmit" type="submit" value="Send"/></td> <td>Address <input type="text" id="address" name="address" value="50"/><br></td>
<td>File<input type="file" multiple="multiple" id="upfile"></td>
<td><input id="add" type="button" value="Send"/></td>
</tr> </tr>
</table> </table>
</form> </form>