jQuery getScript()- methode

❮ jQuery AJAX-methoden

Voorbeeld

Een JavaScript ophalen en uitvoeren met een AJAX-verzoek:

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

Definitie en gebruik

De methode getScript() wordt gebruikt om een ​​JavaScript op te halen en uit te voeren met behulp van een AJAX HTTP GET-verzoek.


Syntaxis

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