أسلوب jQuery ajaxError ()

❮ طرق jQuery AJAX

مثال

تشغيل مربع تنبيه عند فشل طلب AJAX:

$(document).ajaxError(function(){
  alert("An error occurred!");
});

التعريف والاستخدام

تحدد طريقة ajaxError () وظيفة ليتم تشغيلها عند فشل طلب AJAX.

ملاحظة: اعتبارًا من الإصدار 1.8 من jQuery ، يجب إرفاق هذه الطريقة بالمستند فقط.


بناء الجملة

$(document).ajaxError(function(event,xhr,options,exc))

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

جربها بنفسك - أمثلة


كيفية استخدام معلمة الخيارات للحصول على رسالة خطأ أكثر فائدة.


❮ طرق jQuery AJAX