jQuery getScript () Metode

Metode jQuery AJAX

Contoh

Dapatkan dan jalankan JavaScript menggunakan permintaan AJAX:

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

Definisi dan Penggunaan

Metode getScript() digunakan untuk mendapatkan dan menjalankan JavaScript menggunakan permintaan GET HTTP AJAX.


Sintaksis

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

Metode jQuery AJAX