jQuery ajaxComplete() Metode

❮ jQuery AJAX-metodes

Voorbeeld

Wys 'n "laai"-aanwyserbeeld terwyl 'n AJAX-versoek aan die gang is:

$(document).ajaxStart(function(){
  $("#wait").css("display", "block");
});

$(document).ajaxComplete(function(){
  $("#wait").css("display", "none");
});

Definisie en gebruik

Die ajaxComplete() metode spesifiseer 'n funksie wat uitgevoer moet word wanneer 'n AJAX-versoek voltooi is.

Let wel: Vanaf jQuery weergawe 1.8 moet hierdie metode slegs aan dokument geheg word.

Anders as ajaxSuccess(), sal funksies wat met die ajaxComplete()-metode gespesifiseer is, loop wanneer die versoek voltooi is, selfs dit is nie suksesvol nie.


Sintaksis

$(document).ajaxComplete(function(event,xhr,options))

Parameter Description
function(event,xhr,options) Required. Specifies the function to run when the request completes
Additional parameters:
  • event - contains the event object
  • xhr - contains the XMLHttpRequest object
  • options - contains the options used in the AJAX request

❮ jQuery AJAX-metodes