Ajax get request with jQuery.get method

In jQuery get method is used to make get Ajax http requests. When we want to retrieve data from server without refreshing entire webpage, we can use jQuery.get method. It takes 3 arguments, first the URL from where we need to get data from server side. Second data which we need to pass to server as query string, third is callback function when the request gets complete then this callback function gets called. Example of jQuery get method is mentioned below: jQuery.get() method example


<html>
<head>
    <title>Example</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>

    <button id="btnget">Get Student Data</button>

    <script> 
        $(document).ready(function () {
            $('#btnget').click(function() {
                $.get("getStudent.php", { studentId: 5 }, function(studentdata) {
                alert(studentdata);
            });
          });
        });
    </script>
</body>
</html>