jQuery AJAX serializeArray() Method

프로그램&DB/AJAX 2011. 8. 23. 14:19 Posted by Josep.H.S

jQuery AJAX serializeArray() Method

jQuery AJAX Methods jQuery AJAX Methods

Example

Output the result of form values serialized as arrays:

$("button").click(function(){
  x=$("form").serializeArray();
  $.each(x, function(i, field){
    $("#results").append(field.name + ":" + field.value + " ");
  });
});

Try it yourself »

Definition and Usage

The serializeArray() method creates an array of objects (name and value) by serializing form values.

You can select one or more form elements (like input and/or text area), or the form element itself.

Syntax

$(selector).serializeArray()



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

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

jQuery AJAX serialize() Method  (0) 2011.08.23
jQuery AJAX $.post() 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

jQuery AJAX serialize() Method

프로그램&DB/AJAX 2011. 8. 23. 14:17 Posted by Josep.H.S

jQuery AJAX serialize() Method

jQuery AJAX Methods jQuery AJAX Methods

Example

Output the result of serialized form values:

$("button").click(function(){
  $("div").text($("form").serialize());
});

Try it yourself »

Definition and Usage

The serialize() method creates a URL encoded text string by serializing form values.

You can select one or more form elements (like input and/or text area), or the form element itself.

The serialized values can be used in the URL query string when making an AJAX request.

Syntax

$(selector).serialize()



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

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

jQuery AJAX serializeArray() Method  (0) 2011.08.23
jQuery AJAX $.post() 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

jQuery AJAX $.post() Method

프로그램&DB/AJAX 2011. 8. 23. 14:15 Posted by Josep.H.S

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

jQuery AJAX $.param() Method

프로그램&DB/AJAX 2011. 8. 23. 14:14 Posted by Josep.H.S

jQuery AJAX param() Method

jQuery AJAX Methods jQuery AJAX Methods

Example

Output the result of a serialized object:

$("button").click(function(){
  $("div").text($.param(personObj));
});

Try it yourself »

Definition and Usage

The param() method creates a serialized representation of an array or an object.

The serialized values can be used in the URL query string when making an AJAX request.

Syntax

$.param(object,trad)

Parameter Description
object Required. Specifies an array or object to serialize
trad Optional. A Boolean value specifying whether or not to use the traditional style of param serialization



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

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

jQuery AJAX serialize() Method  (0) 2011.08.23
jQuery AJAX $.post() Method  (0) 2011.08.23
jQuery AJAX load() Method  (0) 2011.08.23
jQuery AJAX $.getScript() Method  (0) 2011.08.23
jQuery AJAX $.getJSON() Method  (0) 2011.08.23

jQuery AJAX load() Method

프로그램&DB/AJAX 2011. 8. 23. 14:14 Posted by Josep.H.S

jQuery AJAX load() Method

jQuery AJAX Methods jQuery AJAX Methods

Example

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

$("button").click(function(){
  $("div").load('demo_ajax_load.txt');
});

Try it yourself »

Definition and Usage

The load() method loads data from a server using an AJAX request, and places the returned data into the specified element.

Note: There is also a jQuery Event method called load. Which one is called, depends on the parameters.

Syntax

$(selector).load(url,data,function(response,status,xhr))

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(response,status,xhr) Optional. Specifies the function to run when the request completes

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


Examples

Try it Yourself - Examples

Make an AJAX request, and send data with the request
How to use the data parameter to send data with the AJAX request (this example uses the an example explained in our AJAX Tutorial)

Make an AJAX request and use a callback function
How to use the function parameter to work with the data result from the AJAX request.

Make an AJAX request with an error
How to use the function parameter to deal with errors in an AJAX request (using the XMLHttpRequest parameter).



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

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

jQuery AJAX $.post() Method  (0) 2011.08.23
jQuery AJAX $.param() Method  (0) 2011.08.23
jQuery AJAX $.getScript() Method  (0) 2011.08.23
jQuery AJAX $.getJSON() Method  (0) 2011.08.23
jQuery AJAX $.get() Method  (0) 2011.08.23

jQuery AJAX $.getScript() Method

프로그램&DB/AJAX 2011. 8. 23. 14:13 Posted by Josep.H.S

jQuery AJAX getScript() Method

jQuery AJAX Methods jQuery AJAX Methods

Example

Get and run a JavaScript using an AJAX request:

$("button").click(function(){
  $.getScript("demo_ajax_script.js");
});

Try it yourself »

Definition and Usage

The getScript() method is used to get and execute a JavaScript using an AJAX HTTP GET request.

Syntax

$(selector).getScript(url,success(response,status))

Parameter Description
url Required. Specifies the url to send the request to
success(response,status) 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")



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

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

jQuery AJAX $.param() Method  (0) 2011.08.23
jQuery AJAX load() Method  (0) 2011.08.23
jQuery AJAX $.getJSON() Method  (0) 2011.08.23
jQuery AJAX $.get() Method  (0) 2011.08.23
jQuery AJAX ajaxSuccess() Method  (0) 2011.08.23

jQuery AJAX $.getJSON() Method

프로그램&DB/AJAX 2011. 8. 23. 14:12 Posted by Josep.H.S

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

jQuery AJAX $.get() Method

프로그램&DB/AJAX 2011. 8. 23. 14:11 Posted by Josep.H.S

jQuery AJAX get() Method

jQuery AJAX Methods jQuery AJAX Methods

Example

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

$("button").click(function(){
  $.get("demo_ajax_load.txt", function(result){
    $("div").html(result);
  });
});

Try it yourself »

Definition and Usage

The get() method is used to perform an AJAX HTTP GET request.

Syntax

$(selector).get(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 $.getScript() Method  (0) 2011.08.23
jQuery AJAX $.getJSON() Method  (0) 2011.08.23
jQuery AJAX ajaxSuccess() Method  (0) 2011.08.23
jQuery AJAX ajaxStop() Method  (0) 2011.08.23
jQuery AJAX ajaxStart() Method  (0) 2011.08.23

jQuery AJAX ajaxSuccess() Method

프로그램&DB/AJAX 2011. 8. 23. 14:11 Posted by Josep.H.S

jQuery AJAX ajaxSuccess() Method

jQuery AJAX Methods jQuery AJAX Methods

Example

Trigger an alert box when an AJAX request completes successfully:

$("div").ajaxSuccess(function(){
  alert("AJAX request successfully completed");
});

Try it yourself »

Definition and Usage

The ajaxSuccess() method specifies a function to be run when an AJAX request is successfully completed.

Syntax

$(selector).ajaxSuccess(function(event,xhr,options))

Parameter Description
function(event,xhr,options) Required. Specifies the function to run if the request succeeds
Additional parameters:
  • event - contains the event object
  • xhr - contains the XMLHttpRequest object
  • options - contains the options used in the AJAX request


Examples

Try it Yourself - Examples

Use the options parameter
How to use the options parameter to restrict the function to AJAX requests for a specific file.



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

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

jQuery AJAX $.getJSON() Method  (0) 2011.08.23
jQuery AJAX $.get() Method  (0) 2011.08.23
jQuery AJAX ajaxStop() Method  (0) 2011.08.23
jQuery AJAX ajaxStart() Method  (0) 2011.08.23
jQuery AJAX $.ajaxSetup() Method  (0) 2011.08.23

jQuery AJAX ajaxStop() Method

프로그램&DB/AJAX 2011. 8. 23. 14:10 Posted by Josep.H.S

jQuery AJAX ajaxStop() Method

jQuery AJAX Methods jQuery AJAX Methods

Example

Trigger an alert box when all AJAX requests have completed:

$("div").ajaxStop(function(){
  alert("All AJAX requests completed");
});

Try it yourself »

Definition and Usage

The ajaxStop() method specifies a function to run when ALL AJAX requests have completed.

When an AJAX request completes, jQuery checks if there are any more AJAX requests. The function specified with the ajaxStop() method will run if no other requests are pending.

Syntax

$(selector).ajaxStop(function())

Parameter Description
function() Required. Specifies the function to run when all AJAX requests have completed



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

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

jQuery AJAX $.get() Method  (0) 2011.08.23
jQuery AJAX ajaxSuccess() Method  (0) 2011.08.23
jQuery AJAX ajaxStart() Method  (0) 2011.08.23
jQuery AJAX $.ajaxSetup() Method  (0) 2011.08.23
jQuery AJAX ajaxSend() Method  (0) 2011.08.23