메뉴 건너뛰기

조회 수 6702 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

AJAX 메서드 형식

$.ajax({
   type: "POST"
   , url: 요청페이지
   , data: 파라미터 문자열
   , success: 응답 처리 핸들러
   , error: function(err) { alert('error : ' + err.status); }  에러 처리 핸들러
});

사용예
request.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
< html>
< head>
< meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
< title>JQuery Examples</title>
< script type="text/javascript" src="/scripts/jquery-1.5.1.min.js" ></script>
< style type="text/css">

</style>

<script type="text/javascript">

$().ready(function() {
 $('#submit').click(function() {
  var name = $('.uname').val();
  var data = 'uname=' + name;
  
  $.ajax({
   type: "POST"
   , url: "welcome.jsp"
   , data: data
   , success: handler
   , error: function(err) { alert('error : ' + err.status); }
  });
  
  return false;
 });
 
 function handler(val) {
  $('#message').html(val);
 }
});
 
< /script>
< /head>   
< body>    
 <form>       
  <label>Enter your Name</label>
  <input type="text" name="uname" class="uname" /> <br />
  <input type="submit" id="submit" />
 </form>
 <div id="message"></div>
< /body>
< /html> 



welcome.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
   
< %
 request.setCharacterEncoding("UTF-8");
 String name = (request.getParameter("uname") != null ) ? request.getParameter("uname") : "";
 
 out.print("Welcome " + name);
 
%>


List of Articles
번호 제목 날짜 조회 수
157 안드로이드 - 색상 리소스 (Color Resource) 추가 </color> file 2021.03.31 551
156 안드로이드 - 뷰페이저(ViewPager) 구현 file 2021.04.02 323
155 안드로이드 - 버튼 이벤트 처리방법 정리 (리스너 구현 및 이벤트 핸들링) file 2021.03.31 343
154 안드로이드 - 문자열 배열 리소스 추가하기 <string-array> file 2021.03.31 811
153 안드로이드 - 문자열 리소스를 활용한 다국어 지원 file 2021.03.31 282
152 안드로이드 - 문자열 리소스(Resource) 추가 및 참조하기 file 2021.03.31 906
151 안드로이드 - 명시적 인텐트(Explicit Intent)와 암시적 인텐트 (Implicit Intent) file 2021.04.01 324
150 안드로이드 - 리스트뷰(ListView) 구현 file 2021.04.01 490
149 안드로이드 - 리사이클러뷰 (RecyclerView) notifyDataSetChanged 실행 시 깜빡 거리는 현상 2021.04.02 749
148 안드로이드 - 리사이클러 뷰(RecyclerView) 구현 file 2021.04.01 390
147 안드로이드 - 리니어 레이아웃 (Linear Layout) file 2021.03.29 319
146 안드로이드 - 랠러티브 레이아웃(Relative Layout) file 2021.03.29 239
145 안드로이드 - 네비게이션 드로어(Navigation Drawer)를 활용하여 슬라이드 메뉴 구현하기 file 2021.04.01 1874
144 안드로이드 - 날짜 및 시간 정보 입력받기 (DatePickerDialog / TimePickerDialog) file 2021.04.01 1773
143 안드로이드 - 갤러리에서 이미지 가져오기 2021.04.02 666
142 안드로이드 - Text 입력 이벤트 처리 - TextWatcher file 2021.04.02 557
141 안드로이드 - switch를 사용법 및 구현 file 2021.04.02 1282
140 안드로이드 - SQLiteDatabase 구현하기 file 2021.04.01 249
139 안드로이드 - SnackBar를 사용해 팝업창 띄우기 file 2021.03.31 282
138 안드로이드 - SharedPreferences에 앱 정보 저장하기 file 2021.04.02 395
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 13 Next
/ 13

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved