jQuery get() 메서드
예시
페이지에 HTTP GET 요청을 보내고 결과를 다시 받으십시오.
$("button").click(function(){
$.get("demo_test.asp", function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
});
정의 및 사용
$.get() 메서드는 HTTP GET 요청을 사용하여 서버에서 데이터를 로드합니다.
예
"test.php"를 요청하지만 반환 결과를 무시합니다.
$.get("test.php");
"test.php"를 요청하고 요청과 함께 몇 가지 추가 데이터를 보냅니다(반환 결과 무시):
$.get("test.php", { name:"Donald", town:"Ducktown" });
"test.php"를 요청하고 데이터 배열을 서버에 전달합니다(반환 결과 무시):
$.get("test.php", { 'colors[]' : ["Red","Green","Blue"] });
"test.php"를 요청하고 요청 결과를 경고합니다.
$.get("test.php", function(data){
alert("Data: " + data);
});
통사론
$.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:
|