SoFunction
Updated on 2025-03-06

jquery global AJAX event usage code


<html xmlns="http:///1999/xhtml">
<head>
<title>jQuery Ajax - AjaxEvent</title>
<script src="../jquery-1.4." type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#btnAjax").bind("click", function(event)
{
$.get("",{"resultType":"dddd"},function(data){ $("#divResult").html(Date);});
})
//Execute the function when the AJAX request is completed
$("#divResult").ajaxComplete(function(evt, request, settings) { $(this).append('<div>ajax execution completed</div><br />'); })
//Execute function when an error occurs in AJAX request
$("#divResult").ajaxError(function(evt, request, settings) { $(this).append('<div>ajax execution error</div><br />'); })
//AJAX executes the function before sending the request
$("#divResult").ajaxSend(function(evt, request, settings) { $(this).append('<div>ajax before execution sending</div><br />'); })
//Execute function at the beginning of the AJAX request
$("#divResult").ajaxStart(function() { $(this).append('<div>ajax starts execution</div><br />'); })
//Execute the function at the end of the AJAX request
$("#divResult").ajaxStop(function() { $(this).append('<div>ajax execution end</div><br />'); })
//Execute function when AJAX request is successful
$("#divResult").ajaxSuccess(function(evt, request, settings) { $(this).append('<div>ajax execution successfully</div><br />'); })
});
</script>
</head>
<body>
<br /><button >Send Ajax request</button><br/>
<div ></div>
</body>
</html>