??? Ajax ???
??? Ajax ???
???? Ajax ??? ?? ? ??? ?? ??? Ajax ???? ????? ???.
jQuery.ajaxSetup()? ?? ??? true? ???? ??? ?? ??? ???? ?? ajax?? ??????.
??:
1. ??? ???? ??? ? ?????? ???? ??? JSONP ????? ???? ????.
2. jQuery1.9 ????? ?? ?? ajax ??? ??, ? $(document)? ?????? ???. 3. $.ajax() ?? $. ajax ?? ??? ajaxSetup()? ?? ??? true? ??? ???? ??? ? ???, false? ???? ??? ? ????.
jQuery.ajaxSetup(options)? options ???? ???? ?? ??? ????:
globalType: Boolean ? ???: true
??: ?? Ajax ???? ????? ??
? ??? ?? Ajax ???? ????? ??? ???? ? ?????. ??? Ajax ???? Ajax ??? ?? ???? ??? ??????. ?? ???? ??? ????.
?? ???? ? ???? ??? ??? ?????.<!doctype html> <html> <head> <meta charset="utf-8"/> <title>jQuery Ajax - AjaxEvent</title> <script src="http://code.jquery.com/jquery-3.1.1.min.js"></script> <script> $(document).ready(function() { $("#btnAjax").bind("click", function(event) { $.get("../data/AjaxGetMethod.aspx"); }); $("#divResult").ajaxComplete(function(evt, request, settings) { $(this).append('<div>ajaxComplete</div>'); }); $("#divResult").ajaxError(function(evt, request, settings) { $(this).append('<div>ajaxError</div>'); }); $("#divResult").ajaxSend(function(evt, request, settings) { $(this).append('<div>ajaxSend</div>'); }); $("#divResult").ajaxStart(function() { $(this).append('<div>ajaxStart</div>'); }); $("#divResult").ajaxStop(function() { $(this).append('<div>ajaxStop</div>'); }); $("#divResult").ajaxSuccess(function(evt, request, settings) { $(this).append('<div>ajaxSuccess</div>'); }); }); </script> </head> <body> <br /><button id="btnAjax">send Ajax request</button><br/> <div id="divResult"></div> </body> </html>

? ??? ??(???)
$.ajaxComplete()
?: HTML ??:
<div class="trigger">Trigger</div><div class="result"></div><div class="log"></div>
jquery ??:
$( document ).ajaxComplete(function() { $( ".log" ).text( "Triggered ajaxComplete handler." ); }); $( ".trigger" ).click(function() { $( ".result" ).load( "ajax/test.html" ); });
???? class=? ?? ??? ??? ? Trigger ?? html ??? ????, ??? ??? ? class=log ??? ?? ??? ?????.
?? Ajax ??? ???? ajaxComplete ???? ????? ??? ?? ????? ???
$( document ).ajaxComplete(function( event, xhr, settings ) { if ( settings.url === "ajax/test.html" ) { $( ".log" ).text( "Triggered ajaxComplete handler. The result is " + xhr.responseText ); } });
Syntax form
$(document).ajaxComplete(function(event,xhr,options))
??? ?? ajax ??? ??? ? ???? ??? ajax ??? ?? ??? ????, ???? ??? URL? ???? ? ??? URL? ??? ?????. , ?????.
$.ajaxError()
$(document).ajaxError(function(event,xhr,options,exc))
ajaxerror ???? ??? ??? ??? ??, jqXHR ??(jQuery 1.5 ??? XHR ??), ??? ??? ?? ??? ?????.
HTTP ??? ???? ? ?? ????(thownError)? "?? ? ??" ?? "?? ?? ??"? ?? HTTP ??? ??? ??? ????
?? ??? ?? URL? ???? ???? ????? ?????. :
ajaxSend()
send()? ?? ? ??????.
ajaxSuccess()? ??? ??? ? ??????. ajaxComplete? ?? ajaxComplete? ??? ???? ???? ??? ????. ??? ???????.
?? ??? ??
ajaxStart(), ajaxStop()
? ???? ?? ajax ??? ?? ????. ajaxStart() ???? ? ?? ajax ??? ??? ? ??????. ??? ajax ??? ???? ajaxStop() ???? ??????. ???? ajaxSend() ? ajaxComplete? ???? ? ajax ??? ?? ????.
??? ????? ? ?? 3?? ??? ???? ?? ajaxStart()? ? ?? ??? ??? ? ????? ajaxStop()? ??? ??? ?? ? ?????? ?? ???? ?? ?? ??? ?????. ????. Ajax ?? ??? ???? ??? ?? ??? ????? ????
.ajaxStart( handler() )
.ajaxStop( handler() )