본문 바로가기

프로그램&DB/AJAX

jQuery AJAX $.post() Method

jQuery AJAX post() Method

jQuery AJAX Methods jQuery AJAX Methods

Example

Change the text of a div element using an AJAX POST request:

$("input").keyup(function(){
  txt=$("input").val();
  $.post("demo_ajax_gethint.asp",{suggest:txt},function(result){
    $("span").html(result);
  });
});

Try it yourself »

Definition and Usage

The post() method is used to perform an AJAX HTTP POST request.

Syntax

$(selector).post(url,data,success(response,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
success(response,status,xhr) Optional. Specifies the function to run if the request succeeds
Additional parameters:
  • response - contains the result data from the request
  • status - contains the status of the request ("success", "notmodified", "error", "timeout", or "parsererror")
  • xhr - contains the XMLHttpRequest object
dataType Optional. Specifies the data type expected of the server response.
By default jQuery performs an automatic guess.
Possible types:
  • "xml" - An XML document
  • "html" - HTML as plain text
  • "text" - A plain text string
  • "script" - Runs the response as JavaScript, and returns it as plain text
  • "json" - Runs the response as JSON, and returns a JavaScript object
  • "jsonp" - Loads in a JSON block using JSONP. Will add an "?callback=?" to the URL to specify the callback



[출처] http://www.w3schools.com

'프로그램&DB > AJAX' 카테고리의 다른 글

jQuery AJAX serializeArray() Method  (0) 2011.08.23
jQuery AJAX serialize() Method  (0) 2011.08.23
jQuery AJAX $.param() Method  (0) 2011.08.23
jQuery AJAX load() Method  (0) 2011.08.23
jQuery AJAX $.getScript() Method  (0) 2011.08.23