jQuery getScript()เมธอด

❮ วิธีการ jQuery AJAX

ตัวอย่าง

รับและเรียกใช้ JavaScript โดยใช้คำขอ AJAX:

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

ความหมายและการใช้งาน

เมธอด getScript() ใช้สำหรับรับและรัน JavaScript โดยใช้คำขอ AJAX HTTP GET


ไวยากรณ์

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