새소식

인기 검색어

카테고리 없음

ajax

  • -
<script type="text/javascript"> $(document).ready(function (){ $("input[name='buttonSubmit']").click(function() { // 제출 버튼 이벤트 지정 console.log('ajax실행'); <%-- <% --%> // if(id == null){ <%-- %> --%> // alert("로그인이 필요합니다."); // location.href='./login.do'; <%-- <% --%> // }else{ <%-- %> --%> const id = 'mkc'; $.ajax({ type: "POST", // HTTP Method url: "./blog-single", // 목적지 data: {userid : id, content :$("#messageCM").val() // 전송 데이터 } }).done(function(data){ console.log('success') }).fail(function (Response) { console.log('에러') }); }); }); </script>

기존 ajax에서는 아래처럼 사용했지만 현 jquery에서는 done fail을 사용하여야한다

success: function (data) { $('#CityID').html(data); }, error: function (ajaxContext) { alert(ajaxContext.responseText) }
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.