In jQuery .get() method loads data from the server by using the GET HTTP request. This method returns XMLHttpRequest object.
Syntax
$.get( url, [data], [callback], [type] )
Parameters
- url : String containing the URL at which request is to be sent
- data : This is an optional parameter that represents key/value pairs that will be sent to the server.
- callback: This optional parameter represents the function which is to be executed whenever the data is loaded successfully.
- type : This parameter represents type of data to be returned to the callback function i.e “xml”, “script”, “json”, “html”, “html”, “jsonp”, or “text”.
Example:
// Result.php file <?php if( $_REQUEST["name"] ) { $name = $_REQUEST['name']; echo "Welcome ". $name; } ?> |
chevron_right
filter_none
<html> <head> <script type="text/javascript" src= </script> <script type="text/javascript" language="javascript"> $(document).ready(function() { $("#driver").click(function(event) { $.get( "result.php", { name: "GFG" }, function(data) { $('#stage').html(data); }); }); }); </script> </head> <body> <p>Click on the button to load result file </p> <span id="stage" style="background-color:#cc0;"> GeeksForGeeks </span> <div> <input type="button" id="driver" value="Load Data" /> </div> </body> </html> |
chevron_right
filter_none
Output:
Before clicking on the button:

After clicking on the button:

Recommended Posts:
- jQuery | Misc get() Method
- jQuery | jQuery.fx.interval Property with example
- jQuery | jQuery.fx.off Property
- jQuery | jQuery.support Property
- jQuery | jquery Property
- jQuery | Get Content and Attributes
- jQuery | Get and Set CSS Classes
- Get the height of the hidden element in jQuery
- How to get text of specific option tag using jQuery?
- How to get the size of screen, current web page and browser window using jQuery?
- How to get selected text from a drop-down list using jQuery?
- Get the current URL using jQuery?
- How to get form data using JavaScript/jQuery?
- JQuery | Get the text of a span element
- How to get the ID of the clicked button using JavaScript / jQuery ?
- How to get all selected checkboxes in an array using jQuery ?
- JQuery | Get the n-th level parent of an element
- Get the numeric part of CSS property using jQuery
- How to get the input file size in jQuery ?
- How to get focused element using jQuery?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

