$(selector).getScript(url, success(response, status))
Parameters: It contains two parameters as mentioned above and described below:
- url: It is required parameter. It holds the url to whom the request is send to.
- success(response, status): It is optional parameter. It holds the function to run if the request got success.
- response: It holds the result data from the request.
- status: It holds the status of the request like- “success”, “notmodified”, “error”, “timeout”, or “parsererror”.
The test.js file stored on server and it will load after clicking the change content button.
- Before click on the button:
- After click on the button:
Example 2: This example use getScript() Method to display an alert message.
- Before click on the button
- After click on the button
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.