$.get() Method in jQuery


$.get() method used load data from the server with an HTTP GET request.

Example:

The following example show, how to send parameters and get data from sample.php using jQuery get() method.

 
<html>
  <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
  <body>
    <div id='res'></div>
  </body>
  <script>
    $(document).ready(function(){
      $.get("sample.php",{name:"Tom"},function(data){
        $("#res").html(data);
      });
    });
  </script>
</html>
sample.php
<?php 
  echo "Hi ".$_GET["name"].".This is Sample Text from external PHP File";
?>

Output :

Hi Tom.This is Sample Text from external PHP File