jQuery get() Method
Example
Send an HTTP GET request to a page and get a result back:
$("button").click(function(){
$.get("demo_test.asp", function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
});
Try it yourself »
Definition and Usage
The $.get() method loads data from the server using a HTTP GET request.
Examples
Request "test.php", but ignore return results:
$.get("test.php");
Request "test.php" and send some additional data along with the request (ignore return results):
$.get("test.php", { name:"Donald", town:"Ducktown" });
Request "test.php" and pass arrays of data to the server (ignore return results):
$.get("test.php", { 'colors[]' : ["Red","Green","Blue"] });
Request "test.php" and alert the result of the request:
$.get("test.php", function(data){
alert("Data: " + data);
});
Syntax
$.get(URL,data,function(data,status,xhr),dataType)
Parameter | Description |
---|---|
URL | Required. Specifies the URL you wish to request |
data | Optional. Specifies data to send to the server along with the request |
function(data,status,xhr) | Optional. Specifies a function to run if the request succeeds Additional parameters:
|
dataType | Optional. Specifies the data type expected of the server response. By default jQuery performs an automatic guess. Possible types:
|