Syntax:
$.get(URL,callback);
The required URL parameter specifies the URL you wish to request.
The optional callback parameter is the name of a function to be executed if the request succeeds.
The following example uses the $.get()
method to retrieve data from a file on the server:
Example(1)
Step 1:Create index.html to impelement below code.
<button class="btn btn-success">Send an HTTP GET request to a page and get the result back</button>
Step 2:Create demo_ajax.asp file and write below texts in it.
<% response.write(" Hi ....Am Form External asp File ") %>
<script> $(document).ready(function(){ $("button").click(function(){ $.get("demo_ajax.asp", function(data, status){ alert("Data: " + data + "\nStatus: " + status); }); }); }); </script>
<!DOCTYPE html> <html> <head> <title>How To Use AJAX Load Method In Jquery With Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <style> body { background: black; } </style> <body> <div class="container"> <br><br><br><br> <div class="text-center"> <h2 id="color" style="color: White;">AJAX Load Method In Jquery </h2> </div> <br> <div class="well"> <button class="btn btn-success">Send an HTTP GET request to a page and get the result back</button> </div> </div> </body> </html> <script> $(document).ready(function(){ $("button").click(function(){ $.get("demo_ajax.asp", function(data, status){ alert("Data: " + data + "\nStatus: " + status); }); }); }); </script>