jQuery get() Method

jQuery get() method used to loads data from the server using a HTTP GET request.


Here is a syntax for the get() method

$.get( url, data, function(data, textStatus, jqXHR), dataType );
Parameter Type Description
URL String Required. Specifies the URL to send the request to.
data Object
Optional. Specifies data to sent to the server with the request.
function(data, textStatus, jqXHR) Function Optional. Specifies callback function that is run if the request succeeds.
Additional parameters
  • data - contains the result data from the request
  • textStatus - contains the status of the request
  • jqXHR - contains the XMLHttpRequest object
dataType String Optional. Specifies the data type expected from the server response.
Default: Automatic Guess (xml, html, text, script, json, jsonp)


if( $_REQUEST["name"] )
   $name = $_REQUEST["name"];
   echo "Welcome ". $name;

Here, in this example get() method call when click on button.

<!DOCTYPE html>
  <title>jQuery get() method</title>
  <script src="jquery-latest.min.js"></script>
        $.get("get_method.php", {name: "Paul"}, function(data){
  <div id="msg">This text replace with new contains</div>
  <br />
  <button>Click here to call get() method</button>

Run it...   »

More Examples

Request the "get_method.php", but ignore the return results:

$.get( "get_method.php" );

Request the "get_method.php" URL and send some additional data along with the request:

$.get( "get_method.php", { name: "Paul", city: "London" } );

Request the "get_method.php" and pass arrays of data to the server:

$.get( "get_method.php", { "hobbies[]": ["Cooking", Gardening", "Knitting"] } );

Request the "get_method.php" and alert the result of the request:

$.get( "get_method.php", function(data){
  alert("Data Received: " + data);