Easy Tutorial
❮ Event On Jq Event Relatedtarget ❯

jQuery get() Method

jQuery AJAX Methods

Example

Send an HTTP GET request to a page and retrieve the result:

$("button").click(function(){
    $.get("/try/ajax/demo_test.php",function(data,status){
        alert("Data: " + data + "\nStatus: " + status);
    });
});

Definition and Usage

The $.get() method loads data from the server using an HTTP GET request.


Examples

Request "test.php" but ignore the return result:

Request "test.php" and send some additional data with the request (ignore the return result):

Request "test.php" and pass an array of data to the server (ignore the return result):

Request "test.php" and alert the result of the request:


Syntax

Parameter Description
URL Required. Specifies the URL you wish to request.
data Optional. Specifies data to be sent to the server along with the request.
function(data,status,xhr) Optional. Specifies a function to be run when the request succeeds. <br>Additional parameters: <br> data - Contains the resulting data from the request<br> <br>status - Contains the status of the request ("success", "notmodified", "error", "timeout", "parsererror")<br> <br>xhr - Contains the XMLHttpRequest object
dataType Optional. Specifies the type of data expected from the server response. <br>By default, jQuery performs smart detection. <br>Possible types: "xml" - An XML document<br> "html" - HTML as plain text<br> "text" - A plain text string<br> "script" - Runs the response as JavaScript and returns it as plain text<br> "json" - Runs the response as JSON and returns a JavaScript object<br> "jsonp" - Loads in a JSON block using JSONP, adding a "?callback=?" to the URL to specify the callback

jQuery AJAX Methods

❮ Event On Jq Event Relatedtarget ❯