728x90
    
    
  반응형
    
    
    
  [JQuery] 데이터 조회시 로딩 이미지 보여주기(Ajax)
ajax 코드
$.ajax({
	type : "POST",
	url : currentHostPath+"요청주소",
	data : {
		key : value
	},
	// 로딩 이미지 보여주기
	beforeSend:function(){
		$('.wrap-loading').removeClass('display-none');
	},
	// 로딩 이미지 감추기
	complete:function(){
		$('.wrap-loading').addClass('display-none');
	},
	success : function(filePath) {
		printJS(filePath);
	},
	error : function(data) {
		console.log("fail: ",data);
	}
});
css
/* page-loading css */
.wrap-loading{ /*화면 전체 어둡게*/
    position: fixed;
    left:0;
    right:0;
    top:0;
    bottom:0;
    background: rgba(0,0,0,0.2); /*not in ie */
    filter: progid:DXImageTransform.Microsoft.Gradient(startColorstr='#20000000', endColorstr='#20000000');    /* ie */
    
}
.wrap-loading div{ /*로딩 이미지*/
    position: fixed;
    top:50%;
    left:50%;
    margin-left: -21px;
    margin-top: -21px;
}
html
<div class="wrap-loading display-none">
	<div><img src="./images/loading1.gif"  style="width:50px" /></div>
</div>
* 참고문헌
Ajax를 이용한 데이터 조회시 로딩 로딩 이미지 보이기(jquery이용)
홈페이지를 볼 때 가끔 조회하는 동안 로딩 이미지를 보게 됩니다. 저도 잘 몰랐는데 너무 간단하네요. 다음과 같이 jquery에서 지원하는 ajax함수인데요. beforeSend에서 이미지를 보여주고 complete에
skylhs3.tistory.com
728x90
    
    
  반응형
    
    
    
  'Programing > Javascript, JQuery' 카테고리의 다른 글
| [JavaScript] Number.MAX_SAFE_INTEGER && Number.MIN_SAFE_INTEGER (0) | 2021.05.27 | 
|---|---|
| [JavaScript] Math 함수 정리 (1) | 2021.05.22 | 
| [javascript] 테이블 셀 병합 (jQuery) (0) | 2021.03.01 | 
| [JavaScript] 숫자 세자리마다 콤마 찍기 (0) | 2021.03.01 | 
| [JQuery] file rename, move 참고 blog (0) | 2021.01.13 | 
 
									
								 
									
								 
									
								