jQuery get()Method
Example
Send an HTTP GET request to a page and get back the result:
$("button").click(function(){
$.get("/try/ajax/demo_test.php",function(data,status){
alert("Data:" + data + "\nStatus:" + status);
});
});
Try it yourself »
Definition and Usage
The $.get() method loads data from the server using an HTTP GET request.
Example
Request "test.php", but ignore the returned result:
$.get("test.php");
Request "test.php" and send some extra data along with the request (ignoring the returned result):
$.get("test.php", { name:"Donald", town:"Ducktown" });
Request "test.php" and pass an array of data to the server (ignoring the returned result):
$.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);
});
alert("Data: " + data);
});
Syntax
$.get(URL,data,function(data,status,xhr),dataType)
| Parameter | Description |
|---|---|
| URL | Required. Specifies the URL you need to request. |
| data | Optional. Specifies the data sent to the server along with the request. |
| function(data,status,xhr) | Optional. Specifies the function to run when the request succeeds. Additional parameters:
|
| dataType | Optional. Specifies the expected data type of the server response. By default, jQuery will make an intelligent guess. Possible types:
|
Other Extensions
jQuery AJAX Methods