# jQuery get() Method

jQuery AJAX Methods

## Example

Send an HTTP GET request to a page and get a result back:

$("button").click(function(){
$.get("demo_test.asp",function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
});
Try it yourself »

## Definition and Usage

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

## Examples

Request "test.php", but ignore return results:

$.get("test.php");

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

$.get("test.php", { name:"Donald", town:"Ducktown" });

Request "test.php" and pass arrays of data to the server (ignore return results):

$.get("test.php", { 'colors[]' : ["Red","Green","Blue"] });

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

$.get("test.php", function(data){
alert("Data: " + data);
});

## Syntax

$.get(URL,data,function(data,status,xhr),dataType)

Parameter | Description
--- | ---
URL | Required. Specifies the URL you wish to request
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:

- data - contains the resulting 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

jQuery AJAX Methods

### WEB HOSTING

UK Reseller Hosting

### WEB BUILDING

FREE Website BUILDER Free HTML5 Templates

### W3SCHOOLS EXAMS

HTML, CSS, JavaScript, PHP, jQuery, XML, and ASP Certifications

### SHARE THIS PAGE

### Color Picker

### HTML/CSS

HTML Tutorial HTML5 Tutorial CSS Tutorial CSS3 Tutorial Bootstrap Tutorial

### JavaScript

JavaScript Tutorial jQuery Tutorial jQuery Mobile Tutorial AngularJS Tutorial AJAX Tutorial JSON Tutorial

### Graphics

Canvas Tutorial SVG Tutorial Google Maps Tutorial

### Server Side

SQL Tutorial PHP Tutorial ASP Tutorial ASP.NET Tutorial VBScript Tutorial AppML Tutorial

### Web

Web Building Web Statistics Web Certification

### XML

XML Tutorial DTD Tutorial Schema Tutorial XML DOM Tutorial XPath Tutorial XSLT Tutorial XQuery Tutorial XSL-FO Tutorial RSS Tutorial WSDL Tutorial

### HTML/CSS

HTML Tag Reference HTML Event Reference HTML Color Reference CSS 1,2,3 Reference Bootstrap Reference

### JavaScript

JavaScript Reference HTML DOM Reference jQuery Reference jQuery Mobile Reference Google Maps Reference

### Server Side

PHP Reference SQL Reference ASP Reference VBScript Reference Razor Reference ASP.NET Reference

### XML

XML DOM Reference XSLT Reference XSL-FO Reference XPath Reference XQuery Reference Schema Reference RSS Reference SVG Reference

### HTML Charsets

HTML Character Sets HTML ASCII HTML ANSI HTML Windows-1252 HTML ISO-8859-1 HTML Symbols HTML UTF-8

### HTML/CSS

HTML Examples CSS Examples

### Browser Scripting

JavaScript Examples HTML DOM Examples jQuery Examples jQuery Mobile Examples AngularJS Examples AJAX Examples

### Server Scripting

PHP Examples ASP Examples VBScript Examples Razor Examples .NET Examples

### XML Languages

XML Examples DTD Examples XML DOM Examples XSL Examples XSLT Examples XPath Examples XQuery Examples Schema Examples RSS Examples SVG Examples