jQuery post() 메서드
실시예 1
HTTP POST 요청을 사용하여 서버에서 데이터 로드:
$("button").click(function(){
$.post("demo_test.asp", function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
});
실시예 2
AJAX POST 요청을 사용하여 <div> 요소의 텍스트를 변경합니다.
$("input").keyup(function(){
var txt = $("input").val();
$.post("demo_ajax_gethint.asp", {suggest: txt}, function(result){
$("span").html(result);
});
});
정의 및 사용
$.post() 메서드는 HTTP POST 요청을 사용하여 서버에서 데이터를 로드합니다.
통사론
$(selector).post(URL,data,function(data,status,xhr),dataType)
Parameter | Description |
---|---|
URL | Required. Specifies the url to send the request to |
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:
|