jQuery get() Method

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Ajax Shorthands

What You’ll Learn

$.get() is jQuery’s readable GET shorthand. This tutorial covers both official signatures, how it maps to $.ajax(), the success callback arguments, parsing JSON with the fourth dataType argument, chaining .done(), .fail(), and .always() on the returned jqXHR, the settings-object form since jQuery 1.12, silent error behavior, and when to upgrade to full $.ajax().

01

GET Shorthand

$.get(url, ...)

02

Query Data

Append to URL

03

success

Callback args

04

dataType

json, html, text

05

jqXHR

done/fail/always

06

settings

Since jQuery 1.12

Introduction

Most pages need to load data from a server — a user profile, a list of posts, an HTML fragment for a sidebar. jQuery makes that one line with $.get(). Pass a URL and a callback; jQuery sends an asynchronous HTTP GET request and invokes your function when the server responds successfully.

Under the hood, $.get() is not a separate transport — it is a thin wrapper around jQuery.ajax() with type: "GET" preset. That means you inherit the same jqXHR return value, global Ajax events on document, and Promise-style chaining. When your needs outgrow a one-liner — custom headers, POST bodies, or global: false — you drop down to $.ajax() without changing mental models.

Understanding jQuery.get()

jQuery.get() loads data from a server using an HTTP GET request. The method returns immediately with a jqXHR object while the network call runs in the background. If you pass a success function, jQuery calls it with the response body once parsing completes — the exact type depends on the optional dataType argument or jQuery’s intelligent guess from the Content-Type header.

The optional data argument is a plain object (or string) appended to the URL as query parameters — ideal for search terms, page numbers, or filter flags. Because GET requests should be idempotent reads, keep writes and sensitive payloads on $.post() or full $.ajax() with method: "POST".

💡
Beginner Tip

Always chain .fail() on the jqXHR returned by $.get(). Unlike $.ajax() with an explicit error setting, a bare $.get() fails silently on HTTP errors — users see nothing unless you handle failures.

📝 Syntax

The official jQuery API accepts two signatures:

1. Positional arguments — jQuery.get( url [, data ] [, success ] [, dataType ] )

jQuery
jQuery.get( url [, data ] [, success ] [, dataType ] )

The classic form — URL first, optional query data, optional success callback, optional expected response type.

2. Settings object — jQuery.get( [ settings ] ) (since jQuery 1.12)

jQuery
jQuery.get( [ settings ] )

Pass a single settings object. All $.ajax() options except url are optional; jQuery sets type to "GET" automatically.

Equivalence to $.ajax()

These two calls are identical:

jQuery
// Shorthand
$.get( url, data, success, dataType );

// Expanded — what jQuery does internally
$.ajax( {
  url: url,
  data: data,
  success: success,
  dataType: dataType,
  type: "GET"
} );

success callback signature

  • data — parsed response: XML root, string, script, or JSON object depending on dataType and MIME type.
  • textStatus — string such as "success"; may be undefined for JSONP/cross-domain GET without XHR.
  • jqXHR — the same jqXHR object returned by $.get(); also undefined for some JSONP requests.

Return value

  • $.get() returns a jqXHR object — chain .done(), .fail(), and .always().
  • Handlers can be attached after the request completes; jQuery fires them immediately if already finished.
  • Deprecated jqXHR methods .success(), .error(), and .complete() were removed in jQuery 3.0 — use .done() / .fail() / .always().
  • Call jqXHR.abort() to cancel an in-flight GET request.

⚡ Quick Reference

GoalCode
Basic GET (fire and forget)$.get("/api/items")
GET with query parameters$.get("/search", { q: "jquery", page: 1 })
GET with success callback$.get(url, function(data) { ... })
Expect JSON response$.get(url, fn, "json")
Data + success + dataType$.get(url, { id: 1 }, fn, "json")
Chain success handler$.get(url).done(function(data) { ... })
Handle errors$.get(url).fail(function(xhr, status, err) { ... })
Settings object (1.12+)$.get({ url: "/api", dataType: "json" })
Cancel requestvar req = $.get(...); req.abort();

📋 $.get() vs $.ajax() vs fetch() vs $.post()

Four ways to move data — pick the shortest readable form or the API with the control you need.

$.get()
GET shorthand

$.get(url, data, success) — one-liner for reads; internally calls $.ajax() with type: "GET"

$.ajax()
full control

Every setting exposed — headers, beforeSend, method, dataType, global:false, and jqXHR chaining

fetch()
native API

Browser built-in — no jQuery dependency; does not trigger jQuery global Ajax events

$.post()
POST shorthand

$.post(url, data, success) — same positional pattern for writes; data sent in request body

Use $.get() for simple reads with minimal configuration. Use $.ajax() when you need headers, beforeSend, or global: false. Use $.post() for form submissions and creates. Use fetch() in vanilla JS projects without jQuery.

Examples Gallery

Five progressive examples from a basic GET with a success callback through query parameters, explicit dataType: "json", jqXHR chaining, and the settings-object signature. Each links to a Try-it lab where you can edit and run the code in the browser.

📚 Core Patterns

Load and display data with the positional $.get() signature.

Example 1 — Basic GET with success callback

Fetch a JSON post from JSONPlaceholder and display the title when the request succeeds.

jQuery
$( "#load" ).on( "click", function() {
  $.get(
    "https://jsonplaceholder.typicode.com/posts/1",
    function( data ) {
      $( "#result" ).text( "Title: " + data.title );
    }
  );
} );
Try It Yourself

How It Works

The second argument is the success callback — jQuery invokes it with the response body when the server returns a success status. Without an explicit dataType, jQuery guesses the type from the Content-Type header; JSONPlaceholder sends application/json, so data.title works.

Example 2 — GET with data query object

Pass a plain object as the second argument — jQuery serializes it and appends it to the URL as query parameters.

jQuery
$( "#search" ).on( "click", function() {
  var userId = $( "#user-id" ).val() || 1;

  $.get(
    "https://jsonplaceholder.typicode.com/posts",
    { userId: userId },
    function( posts ) {
      var count = posts.length;
      $( "#result" ).text( "Found " + count + " posts for user " + userId );
    }
  );
} );
Try It Yourself

How It Works

For GET requests, the data object becomes URL query parameters — jQuery handles encoding. This is the standard pattern for filtered lists, paginated feeds, and search boxes. Keep parameter names short and server-documented.

Example 3 — Fourth argument dataType: "json"

Pass "json" as the fourth argument so jQuery parses the body into a JavaScript object before the callback runs.

jQuery
function showUser( userId ) {
  $.get(
    "https://jsonplaceholder.typicode.com/users/" + userId,
    null,
    function( user ) {
      $( "#name" ).text( user.name );
      $( "#email" ).text( user.email );
      console.log( typeof user ); // "object"
    },
    "json"
  );
}

showUser( 1 );
Try It Yourself

How It Works

When you omit data but need dataType, pass null (or undefined) as the second argument — a jQuery 3.x requirement when skipping straight to the success callback slot. With "json", jQuery parses the body; invalid JSON triggers an error path on the jqXHR.

📈 jqXHR & Settings Object

Chain Promise-style handlers and use the jQuery 1.12+ settings signature.

Example 4 — Return jqXHR — chain .done() / .fail() / .always()

Store the jqXHR returned by $.get() and attach handlers with modern Deferred methods instead of the legacy success callback alone.

jQuery
function loadComments( postId ) {
  return $.get( "https://jsonplaceholder.typicode.com/posts/" + postId + "/comments" )
    .done( function( comments, textStatus, jqXHR ) {
      var html = comments.map( function( c ) {
        return "<li>" + c.email + ": " + c.body.substring( 0, 40 ) + "...</li>";
      } ).join( "" );
      $( "#list" ).html( html );
      console.log( "Status:", textStatus, "HTTP:", jqXHR.status );
    } )
    .fail( function( jqXHR, textStatus, errorThrown ) {
      $( "#list" ).html( "<li>Could not load comments (" + textStatus + ")</li>" );
    } )
    .always( function() {
      $( "#spinner" ).hide();
    } );
}

loadComments( 1 );
Try It Yourself

How It Works

Returning the jqXHR from loadComments() lets callers chain further handlers or call .abort(). Prefer .done() / .fail() / .always() over deprecated jqXHR .success() / .error() / .complete() removed in jQuery 3.0.

Example 5 — Settings object $.get({ url, dataType: "json" }) (since 1.12)

When options grow beyond positional arguments, pass a settings object — jQuery sets type to GET automatically.

jQuery
$( "#load-album" ).on( "click", function() {
  $.get( {
    url: "https://jsonplaceholder.typicode.com/albums/1",
    dataType: "json",
    cache: false
  } )
    .done( function( album ) {
      $( "#title" ).text( album.title );
      $( "#id" ).text( "Album #" + album.id + " (user " + album.userId + ")" );
    } )
    .fail( function() {
      $( "#title" ).text( "Album not found." );
    } );
} );
Try It Yourself

How It Works

The settings-object signature accepts any $.ajax() option except you omit type — jQuery forces GET. Use this form when you need cache: false, beforeSend, or other options without dropping to the full $.ajax() call syntax.

🚀 Common Use Cases

  • Load JSON records — fetch a user, post, or product by ID and render fields in the DOM.
  • Filtered lists — pass search terms and pagination as the data query object.
  • HTML partials — retrieve server-rendered fragments and inject with .html() (omit dataType or set "html").
  • Autocomplete — debounced GET as the user types; abort the previous jqXHR on each keystroke.
  • Polling / refresh — periodic $.get() to update a dashboard widget without reloading the page.
  • Prefetch — fire-and-forget GET to warm a cache before the user clicks (chain .done() to store results locally).

🧠 How $.get() Works Internally

1

Expand to $.ajax()

$.get() maps positional args to { url, data, success, dataType, type: "GET" } and delegates to jQuery.ajax().

$.ajax()
2

Return jqXHR immediately

Caller receives a jqXHR object right away — attach .done() / .fail() before or after the response arrives.

jqXHR
3

Global ajaxStart / ajaxSend

Unless overridden with global: false in the settings form, document-level Ajax events fire like any $.ajax() call.

ajaxSend
4

Parse response

jQuery applies dataType converters — JSON becomes an object, HTML stays a string, script may execute.

dataType
5

success + .done()

On HTTP success, the legacy success callback and chained .done() handlers both run with (data, textStatus, jqXHR).

.done()
6

Error path or ajaxComplete

Failures invoke .fail() (not the success callback) — silently if unhandled. .always() and global ajaxComplete run either way.

📝 Notes

  • $.get() is asynchronous — code after the call runs before the response arrives.
  • It is shorthand for $.ajax() with type: "GET" — same jqXHR, same global Ajax events.
  • Silent failure: HTTP errors fail quietly unless you chain .fail() or register a global ajaxError handler.
  • Same-origin policy: cross-domain GET requests require CORS headers on the server; otherwise the browser blocks the response.
  • JSONP and script: script and JSONP requests bypass same-origin restrictions but do not use XHR — jqXHR in success may be undefined.
  • Prefer .done() / .fail() / .always() over deprecated jqXHR .success() / .error() / .complete() (removed in jQuery 3.0).
  • When skipping data but providing dataType in the positional form, pass null as the second argument (jQuery 3.x).
  • The settings-object form $.get({ ... }) is available since jQuery 1.12 — it sets type to GET automatically.

Browser Support

jQuery.get() is part of jQuery’s core Ajax module — not a native DOM API. It works wherever jQuery’s Ajax transport runs: all browsers supported by your jQuery version, including legacy IE with supported jQuery builds.

jQuery 1.0+

jQuery.get() method

Supported in jQuery 1.x, 2.x, and 3.x across all modern browsers and IE with supported jQuery builds. jqXHR promise methods (.done, .fail, .always) arrived in jQuery 1.5. The settings-object signature $.get({ url }) requires jQuery 1.12+. Cross-domain GET requires CORS or JSONP/script transports.

100% With jQuery
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
$.get() Universal

Bottom line: Safe in any jQuery project. Use $.get() for simple reads; $.ajax() when you need full settings; $.post() for writes. fetch() is the native alternative when jQuery is not loaded.

Conclusion

jQuery.get() is the fastest path from URL to callback for read-only HTTP requests. Learn the positional signature (url, data, success, dataType), chain .fail() so errors are not silent, and reach for the settings object when you need cache: false or other $.ajax() options without writing type: "GET" yourself.

When you need to send data in the request body, continue with the jQuery.post() tutorial. When you always expect JSON from a GET endpoint, the dedicated jQuery.getJSON() tutorial is even clearer than passing "json" as the fourth argument.

💡 Best Practices

✅ Do

  • Chain .fail() on every $.get() so users see errors
  • Set dataType: "json" explicitly when you expect JSON from the server
  • Return jqXHR from helper functions so callers can chain or abort
  • Use the data object for query parameters instead of manual string concatenation
  • Upgrade to $.ajax() when you need headers, POST, or global: false

❌ Don’t

  • Assume errors surface automatically — $.get() fails silently by default
  • Send sensitive data in GET query strings — use $.post() over HTTPS
  • Forget CORS — cross-origin $.get() calls fail without server headers
  • Use deprecated jqXHR .success() / .error() / .complete() in jQuery 3.x
  • Leave in-flight requests running after SPA navigation — call .abort() on teardown

Key Takeaways

Knowledge Unlocked

Six things to remember about $.get()

URL in, jqXHR out, chain fail().

6
Core concepts
data 02

Query Data

Append to URL

Filter
cb 03

success

data, status, jqXHR

Callback
json 04

dataType

Parse response

json
xhr 05

jqXHR

done/fail/always

Promise
cfg 06

settings

Since 1.12

Object

❓ Frequently Asked Questions

jQuery.get() is a shorthand for $.ajax() configured as a GET request. Pass a URL, optional data object, optional success callback, and optional dataType — jQuery sends the request asynchronously and returns a jqXHR object. Since jQuery 1.12 you can also pass a single settings object: $.get({ url, data, dataType }). It is the readable one-liner most developers reach for when loading data from a server.
It returns a jqXHR object — a superset of XMLHttpRequest that implements jQuery's Promise interface. Chain .done(fn) for success, .fail(fn) for errors, and .always(fn) for either outcome. You can attach handlers immediately or after the request completes; if it already finished, the callback fires right away. Call jqXHR.abort() to cancel an in-flight GET.
$.get() is sugar for $.ajax({ url, data, success, dataType, type: "GET" }). Use $.get() when you only need a simple GET with minimal options. Use $.ajax() when you need full control: custom headers, beforeSend, POST method, global: false, contentType, or other settings $.get() does not expose as positional arguments.
The success callback signature is function(data, textStatus, jqXHR). data is the parsed response body — a string, HTML fragment, or JavaScript object depending on dataType and Content-Type. textStatus is typically "success". jqXHR is the same object returned by $.get(). For JSONP and some cross-domain GET requests, jqXHR and textStatus may be undefined because no XHR is used.
Yes — if the server returns an error status or the request fails, $.get() does not alert you unless you chain .fail() on the returned jqXHR, register a global ajaxError handler on document, or provide error handling another way. The success callback simply never runs. Always chain .fail() or use .always() when users need feedback on failure.
Use $.get() to read data — fetching JSON, HTML snippets, or search results where parameters go in the query string. Use $.post() to send data that should appear in the request body — form submissions, creating records, or any write operation. Both are shorthands over $.ajax() with preset HTTP methods.
Did you know?

$.get() has existed since jQuery 1.0, but the object returned only became a full jqXHR with Promise methods in jQuery 1.5. The settings-object signature $.get({ url }) arrived in jQuery 1.12 alongside the same change for $.post() and $.getJSON(). Under the hood, every call still routes through jQuery.ajax() — which is why global ajaxStart and ajaxStop fire unless you pass global: false in the settings form.

Next: jQuery.post() Method

Send data in the request body — form submissions, creates, and writes with the POST shorthand.

jQuery.post() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful