jQuery load () method
Examples
The load file "demo_test.txt" content to the specified <div> element:
$("button").click(function(){
$("#div1").load("demo_test.txt");
});
$("#div1").load("demo_test.txt");
});
try it"
Definition and Usage
load () method to load data from the server, and places the returned data to the specified element.
Note: there is a jQuery called load the event method. Which, depending on the parameters of the call.
grammar
$(selector).load(url,data,function(response,status,xhr))
参数 | 描述 |
---|---|
url | 必需。规定您需要加载的 URL。 |
data | 可选。规定连同请求发送到服务器的数据。 |
function(response,status,xhr) |
可选。规定 load() 方法完成时运行的回调函数。 额外的参数:
|
More examples
Generate AJAX request, and sends the data via the request
How to use data parameters via AJAX request to send data (in this example in our AJAX tutorial are explained).
Generate AJAX request and use a callback function
How to use the function parameter data processing results from AJAX request.
Generate AJAX request with errors
How to use the function parameters to process the AJAX request error (using XMLHttpRequest parameter).