Metoda jQuery getScript().

❮ Metody jQuery AJAX

Příklad

Získejte a spusťte JavaScript pomocí požadavku AJAX:

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

Definice a použití

Metoda getScript() se používá k získání a spuštění JavaScriptu pomocí požadavku AJAX HTTP GET.


Syntax

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

❮ Metody jQuery AJAX