본문 바로가기

프로그램&DB/AJAX

jQuery AJAX $.getJSON() Method

jQuery AJAX getJSON() Method

jQuery AJAX Methods jQuery AJAX Methods

Example

Get JSON data using an AJAX request, and output the result:

$("button").click(function(){
  $.getJSON("demo_ajax_json.js",function(result){
    $.each(result, function(i, field){
      $("div").append(field + " ");
    });
  });
});

Try it yourself »

Definition and Usage

The getJSON() method is used to get JSON data using an AJAX HTTP GET request.

Syntax

$(selector).getJSON(url,data,success(data,status,xhr))

Parameter Description
url Required. Specifies the url to send the request to
data Optional. Specifies data to be sent to the server
success(data,status,xhr) Optional. Specifies the function to run if the request succeeds
Additional parameters:
  • data - contains the data returned from the server.
  • status - contains a string containing request status ("success", "notmodified", "error", "timeout", or "parsererror").
  • xhr - contains the XMLHttpRequest object



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

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

jQuery AJAX load() Method  (0) 2011.08.23
jQuery AJAX $.getScript() Method  (0) 2011.08.23
jQuery AJAX $.get() Method  (0) 2011.08.23
jQuery AJAX ajaxSuccess() Method  (0) 2011.08.23
jQuery AJAX ajaxStop() Method  (0) 2011.08.23