jQuery metodo getScript()

❮ Metodi jQuery AJAX

Esempio

Ottieni ed esegui un JavaScript utilizzando una richiesta AJAX:

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

Definizione e utilizzo

Il metodo getScript() viene utilizzato per ottenere ed eseguire un JavaScript utilizzando una richiesta HTTP GET AJAX.


Sintassi

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

❮ Metodi jQuery AJAX