jQuery getScript() Metode

❮ jQuery AJAX-metodes

Voorbeeld

Kry en hardloop 'n JavaScript deur 'n AJAX-versoek te gebruik:

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

Definisie en gebruik

Die getScript() metode word gebruik om 'n JavaScript te kry en uit te voer deur 'n AJAX HTTP GET-versoek te gebruik.


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

❮ jQuery AJAX-metodes