طريقة jQuery load ()

❮ طرق jQuery AJAX

مثال

قم بتحميل محتوى الملف "demo_test.txt" إلى عنصر <div> محدد:

$("button").click(function(){
  $("#div1").load("demo_test.txt");
});

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

تقوم طريقة load () بتحميل البيانات من الخادم وتضع البيانات التي تم إرجاعها في العنصر المحدد.

ملاحظة: هناك أيضًا طريقة jQuery Event تسمى load. أي واحد يسمى ، يعتمد على المعلمات.


بناء الجملة

$(selector).load(url,data,function(response,status,xhr))

Parameter Description
url Required. Specifies the URL you wish to load
data Optional. Specifies data to send to the server along with the request
function(response,status,xhr) Optional. Specifies a callback function to run when the load() method is completed.

Additional parameters:
  • response - contains the result data from the request
  • status - contains the status of the request ("success", "notmodified", "error", "timeout", or "parsererror")
  • xhr - contains the XMLHttpRequest object

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


كيفية استخدام معلمة البيانات لإرسال البيانات مع طلب AJAX (يستخدم هذا المثال المثال الموضح في برنامج AJAX التعليمي الخاص بنا )


كيفية استخدام معلمة الوظيفة للعمل مع نتيجة البيانات من طلب AJAX.


كيفية استخدام معلمة الوظيفة للتعامل مع الأخطاء في طلب AJAX (باستخدام معلمة XMLHttpRequest).


❮ طرق jQuery AJAX