jQuery load() Yöntemi

❮ jQuery AJAX Yöntemleri

Örnek

"demo_test.txt" dosyasının içeriğini belirli bir <div> öğesine yükleyin:

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

Tanım ve Kullanım

load() yöntemi, bir sunucudan veri yükler ve döndürülen verileri seçilen öğeye yerleştirir.

Not: load adında bir jQuery Event yöntemi de vardır. Hangisi denir, parametrelere bağlıdır.


Sözdizimi

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

Kendiniz Deneyin - Örnekler

AJAX Eğitimimizde
açıklanan bir örneği kullanır )


kullanın AJAX isteğinin veri sonucuyla çalışmak için işlev parametresi nasıl kullanılır?


hatalarla başa çıkmak için işlev parametresi nasıl kullanılır (XMLHttpRequest parametresini kullanarak).


❮ jQuery AJAX Yöntemleri