jQuery get () method
Examples
Send an HTTP GET request to the page and get back the results:
$("button").click(function(){
$.get("demo_test.html",function(data,status){
alert("Data: " + data + "nStatus: " + status);
});
});
$.get("demo_test.html",function(data,status){
alert("Data: " + data + "nStatus: " + status);
});
});
try it"
Definition and Usage
$ .get () Method uses the HTTP GET request to load data from the server.
Examples
Request "test.php", but ignore the return result:
$.get("test.php");
Request "test.php" and send some additional data (ignoring the return results) together with the request:
$.get("test.php", { name:"Donald", town:"Ducktown" });
Request "test.php" and pass an array of data to the server (ignore the return results):
$.get("test.php", { 'colors[]' : ["Red","Green","Blue"] });
Request "test.php" and reminded result of the request:
$.get("test.php", function(data){
alert("Data: " + data);
});
alert("Data: " + data);
});
grammar
$.get(URL,data,function(data,status,xhr),dataType)
参数 | 描述 |
---|---|
URL | 必需。规定您需要请求的 URL。 |
data | 可选。规定连同请求发送到服务器的数据。 |
function(data,status,xhr) |
可选。规定当请求成功时运行的函数。 额外的参数:
|
dataType |
可选。规定预期的服务器响应的数据类型。 默认地,jQuery 会智能判断。 可能的类型:
|