Metoda jQuery get() .
Příklad
Odešlete požadavek HTTP GET na stránku a získejte zpět výsledek:
$("button").click(function(){
$.get("demo_test.asp", function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
});
Definice a použití
Metoda $.get() načte data ze serveru pomocí požadavku HTTP GET.
Příklady
Vyžádejte si "test.php", ale ignorujte návratové výsledky:
$.get("test.php");
Vyžádejte si "test.php" a spolu s požadavkem odešlete některá další data (výsledky vrácení ignorujte):
$.get("test.php", { name:"Donald", town:"Ducktown" });
Vyžádejte si "test.php" a předejte pole dat serveru (ignorujte návratové výsledky):
$.get("test.php", { 'colors[]' : ["Red","Green","Blue"] });
Vyžádejte si "test.php" a upozorněte na výsledek požadavku:
$.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:
|