Phương thức jQuery ajaxSend ()

❮ Phương thức jQuery AJAX

Thí dụ

Thay đổi nội dung của phần tử <div> khi yêu cầu AJAX sắp được gửi:

$(document).ajaxSend(function(e, xhr, opt){
  $("div").append("<p>Requesting: " + opt.url + "</p>");
});

Định nghĩa và Cách sử dụng

Phương thức ajaxSend () chỉ định một hàm để chạy khi một yêu cầu AJAX sắp được gửi đi.

Lưu ý: Kể từ phiên bản jQuery 1.8, phương thức này chỉ nên được đính kèm vào tài liệu.


Cú pháp

$(document).ajaxSend(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

❮ Phương thức jQuery AJAX