jQuery ajaxSuccess() Metode

Metode jQuery AJAX

Contoh

Memicu kotak peringatan ketika permintaan AJAX berhasil diselesaikan:

$(document).ajaxSuccess(function(){
  alert("AJAX request successfully completed");
});

Definisi dan Penggunaan

Metode ajaxSuccess() menentukan fungsi yang akan dijalankan ketika permintaan AJAX berhasil diselesaikan.

Catatan: Pada jQuery versi 1.8, metode ini hanya boleh dilampirkan ke dokumen.


Sintaksis

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

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

Cobalah Sendiri - Contoh


Cara menggunakan parameter opsi untuk membatasi fungsi ke permintaan AJAX untuk file tertentu.


Metode jQuery AJAX