Método jQuery getScript()

❮ Métodos jQuery AJAX

Ejemplo

Obtenga y ejecute un JavaScript usando una solicitud AJAX:

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

Definición y uso

El método getScript() se usa para obtener y ejecutar un JavaScript usando una solicitud AJAX HTTP GET.


Sintaxis

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

❮ Métodos jQuery AJAX