<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(document).ajaxStart(function(){ $(this).html("<img src='loading.gif'>"); }); $("button").click(function(){ $("div").load("test.txt"); }); }); </script> </head> <body> <div>홈짱닷컴 주소?</div> <button>알려줘.</button> </body> </html>
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(document).ajaxStart(function(){
$(this).html("<img src='loading.gif'>");
});
$("button").click(function(){
$("div").load("test.txt");
</script>
</head>
<body>
<div>홈짱닷컴 주소?</div>
<button>알려줘.</button>
</body>
</html>
ajaxStart () 메서드 정의와 사용법
AJAX 요청이 시작 될 때 실행할 함수를 지정. PS. jQuery 버전 1.8부터이 메소드는 문서에만 첨부해야 함.
AJAX 요청이 시작 될 때 실행할 함수를 지정.
PS.
jQuery 버전 1.8부터이 메소드는 문서에만 첨부해야 함.
구문
$(document).ajaxStart(function())
매개변수
function () 필수. 요청이 시작 될 때 실행할 함수를 지정.