jQuery getScript() 메서드

❮ jQuery AJAX 메소드

예시

AJAX 요청을 사용하여 JavaScript 가져오기 및 실행:

$("button").click(function(){
  $.getScript("demo_ajax_script.js");
});

정의 및 사용

getScript() 메서드는 AJAX HTTP GET 요청을 사용하여 JavaScript를 가져오고 실행하는 데 사용됩니다.


통사론

$(selector).getScript(url,success(response,status))

Parameter Description
url Required. Specifies the url to send the request to
success(response,status) Optional. Specifies the function to run if the request succeeds
Additional parameters:
  • response - contains the result data from the request
  • status - contains the status of the request ("success", "notmodified", "error", "timeout", or "parsererror")

❮ jQuery AJAX 메소드