jQuery load() 메서드

❮ jQuery AJAX 메소드

예시

"demo_test.txt" 파일의 내용을 특정 <div> 요소에 로드합니다.

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

정의 및 사용

load() 메서드는 서버에서 데이터를 로드하고 반환된 데이터를 선택한 요소에 넣습니다.

참고: load라는 jQuery 이벤트 메서드도 있습니다. 어느 것이 호출되는지는 매개변수에 따라 다릅니다.


통사론

$(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 요청의 데이터 결과로 작업하기 위해 함수 매개변수를 사용하는 방법.


를 처리하기 위해 함수 매개변수를 사용하는 방법(XMLHttpRequest 매개변수 사용).


❮ jQuery AJAX 메소드