Jquery AJAX 속성 beforeSend/complete 예제
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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>필터</title>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#btn").click(function()
{
$.ajax({
type:"post",
url:"http://localhost:8080/JqueryTest/TEST_1.js",
dataType:"json",
success:function(ajaxResult){
alert("sucess");
}, error: function(xhr,status,error){
alert(error);
},
beforeSend:function(){
alert('start');
},
complete:function()
{
alert("end");
}
});
})
});
</script>
</head>
<body>
<form id="form" name="form">
<table>
<tr>
<td><span id="ajaxResult"></span></td>
</tr>
</table>
<table>
<tr>
<td> <p>Jquery AJAX 속성 beforeSend/complete</p>
$(document).ready(function(){ </br>
$("#btn").click(function()</br>
{</br>
$.ajax({</br>
type:"post",</br>
url:"http://localhost:8080/JqueryTest/TEST_1.js",</br>
dataType:"json",</br>
success:function(ajaxResult){</br>
alert("success");</br>
}, error: function(xhr,status,error){</br>
alert(error);</br>
}</br>
beforeSend:function(){</br>
alert('start');</br>
},</br>
complete:function()</br>
{</br>
alert("end");</br>
}</br>
}); </br>
})</br>
}</br>
}); </br>
</td>
</tr>
</table>
</form>
<table id="table2">
<tr>
<td><a href="index.jsp">돌아가기</a></td>
</tr>
<tr>
<td><input type="button" id="btn" value="클릭"/></td>
</tr>
</table>
</body>
</html>