jQuery ajaxSend()เมธอด

❮ วิธีการ jQuery AJAX

ตัวอย่าง

เปลี่ยนเนื้อหาขององค์ประกอบ <div> เมื่อคำขอ AJAX กำลังจะส่ง:

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

ความหมายและการใช้งาน

วิธี ajaxSend() ระบุฟังก์ชันที่จะทำงานเมื่อคำขอ AJAX กำลังจะถูกส่ง

หมายเหตุ:สำหรับ jQuery เวอร์ชัน 1.8 วิธีนี้ควรแนบมากับเอกสารเท่านั้น


ไวยากรณ์

$(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

❮ วิธีการ jQuery AJAX