jQuery .get() Method

Beginner
8 min read
Updated: Oct 2026
5 examples
Live preview

What Is $.get()?

jQuery.get() is a GET shorthand for $.ajax() (since 1.0; settings-object form since 1.12). Pass a URL (and optional data / success / dataType). It returns a jqXHR — chain .done(), .fail(), and .always().

Remember
// Positional form
$.get(url [, data] [, success] [, dataType]);

// Settings form (1.12+)
$.get({ url: "/api/items", dataType: "json" });

// Equivalent to:
$.ajax({ url: url, data: data, success: success, dataType: dataType });
// (type is always GET)
NeedUse
Simple GET$.get(url, success)
GET with query params$.get(url, { id: 1 }, success)
Full control$.ajax()
POST body data$.post()
JSON-only shorthand$.getJSON()

How to Use $.get()

Call it with a URL, optionally send query data, then handle the result.

  1. Call $.get(url) or $.get(url, data, success, dataType).
  2. Or pass a settings object: $.get({ url, data, dataType }).
  3. Chain .done() / .fail() / .always() on the jqXHR (preferred over relying only on the success argument).
  4. Use dataType: "json" when you expect JSON.
  5. Always handle errors — $.get() fails silently by default.
PieceRequired?Role
urlYesEndpoint to request
dataNoQuery string params (object or string)
successNo*function(data, textStatus, jqXHR) (*required if you pass dataType positionally — use null as a placeholder)
dataTypeNojson, html, text, xml, script — or intelligent guess

Pseudocode

Pseudocode
call $.get(url, data, success, dataType)
    → internally $.ajax({ url, data, success, dataType })  // GET
    → returns jqXHR immediately

send HTTP GET asynchronously
    data object → appended as query string

when response arrives:
    if success:
        parse body using dataType (or Content-Type guess)
        run success callback and .done() handlers
    else:
        fail silently unless .fail() or ajaxError is registered
        run .fail() handlers

    run .always() handlers

Cheat Sheet

Keep these patterns handy while loading data with GET.

TopicDetail
Basic$.get("/api/items", fn)
With params$.get("/api", { q: "ada" }, fn)
JSON$.get(url, null, fn, "json") or $.get({ url, dataType: "json" })
Promise chain$.get(url).done(fn).fail(fn).always(fn)
ReturnsjqXHR (XHR + Deferred)
Since1.0 · settings object 1.12 / 2.2
ErrorsSilent unless .fail() or ajaxError
Same originMost Ajax GETs follow the same-origin policy

Live Preview

Run a real $.get() and watch .done() / .fail() update the log.

Live demo uses a public JSON API. Needs network access.

Result
Ready — pick an action and click Run.

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

Example 1 — Basic Success Callback

Fetch a resource and update the page when the GET 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

  1. Click. The handler calls $.get(url, success).
  2. Send. jQuery starts an async GET and returns a jqXHR.
  3. Parse. JSON responses are often auto-detected from Content-Type.
  4. Update. The success callback receives data and updates the DOM.

Example 2 — Send Query Data

Pass a plain object — jQuery appends it to the URL as a query string.

jQuery
$("#search").on("click", function () {
  var userId = $("#user-id").val() || 1;
  $.get(
    "https://jsonplaceholder.typicode.com/posts",
    { userId: userId },
    function (posts) {
      $("#result").text("Found " + posts.length + " posts for user " + userId);
    }
  );
});
Try It Yourself

How It Works

  1. Data. The second argument is serialized into query params.
  2. GET. Nothing goes in the request body — only the URL changes.
  3. Success. The callback receives the filtered list.
  4. Tip. Arrays work too: { "choices[]": ["a", "b"] }.

Example 3 — Explicit dataType: "json"

When you pass dataType positionally, provide null for unused data / success slots as needed.

jQuery
$("#load").on("click", function () {
  $.get(
    "https://jsonplaceholder.typicode.com/users/1",
    null,
    function (user) {
      $("#name").text(user.name);
      $("#email").text(user.email);
    },
    "json"
  );
});
Try It Yourself

How It Works

  1. Placeholder. null skips the data argument so "json" stays in the fourth slot.
  2. Parse. jQuery parses the body into an object before calling success.
  3. Fail. Invalid JSON triggers an error path (use .fail() to catch it).
  4. Alt. $.getJSON() is a dedicated JSON shorthand.

Example 4 — .done() / .fail() / .always()

Prefer chaining on the jqXHR so errors are never silent.

jQuery
$("#ok").on("click", function () {
  $.get("https://jsonplaceholder.typicode.com/posts/1/comments")
    .done(function (comments) {
      $("#list").text("Loaded " + comments.length + " comments");
    })
    .fail(function (_jqXHR, textStatus) {
      $("#list").text("Could not load (" + textStatus + ")");
    })
    .always(function () {
      $("#spinner").text("");
    });
});
Try It Yourself

How It Works

  1. Return. $.get() returns a jqXHR you can chain.
  2. Success. .done() runs with the parsed response.
  3. Error. .fail() runs on HTTP or network failure.
  4. Cleanup. .always() hides the spinner either way.

Example 5 — Settings Object (1.12+)

Pass a plain object when you want named options without positional placeholders.

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);
    })
    .fail(function () {
      $("#title").text("Album not found.");
    });
});
Try It Yourself

How It Works

  1. Object. One settings bag — no null placeholders.
  2. GET forced. The type option is always set to GET for $.get().
  3. Options. Most $.ajax() settings work here (except you stay on GET).
  4. Chain. You still get a jqXHR for .done() / .fail().

Edge Cases & Pitfalls

Watch for these when loading data with $.get().

silent

Errors are silent by default

Without .fail() or ajaxError, a 404 looks like nothing happened. Always handle failures in UI code.

origin

Same-origin policy

Most Ajax GETs cannot read another domain unless CORS allows it. Script/JSONP requests are special cases.

args

Positional dataType needs placeholders

To pass "json" as the fourth argument without data, use null for the data (and success if needed) slots — or use the settings object.

removed

No .success() on jqXHR (3.0+)

Use .done() / .fail() / .always(). The old jqXHR callback methods were removed in jQuery 3.0.

Browser Support

jQuery.get() has been part of jQuery since 1.0. The settings-object form arrived in 1.12 / 2.2. jqXHR Deferred methods (.done() / .fail() / .always()) date from 1.5–1.6. Prefer a current jQuery 3.x build.

✓ Stable · jQuery 1.0+

jQuery.get()

Works wherever your loaded jQuery version runs Ajax. Subject to the browser same-origin policy for typical XHR GETs. Native fetch() is separate and does not trigger jQuery global Ajax events.

100% jQuery Ajax shorthand
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 for everyday apps. Prefer .done()/.fail()/.always(), and never assume success-only callbacks are enough.

Performance Notes

ApproachCostBest for
$.get() (async GET)CheapReading JSON / HTML snippets
$.getJSON()SameJSON-only endpoints
Repeated uncached GETsCostlyDebounce, cache, or abort obsolete calls

Keep requests small, abort obsolete ones when the user navigates away, and avoid firing a new GET on every keystroke without debounce.

Key Takeaways

  • Role: readable GET shorthand — built on $.ajax().
  • Return: jqXHR — chain .done(), .fail(), .always().
  • Data: objects become query-string params on GET.
  • Errors: not silent if you chain .fail() — always do that in UI code.

One line: $.get() is jQuery’s simple async GET — load data, then chain the jqXHR.

Frequently Asked Questions

jQuery.get() is a shorthand for $.ajax() configured as a GET request. Pass a URL, optional data, optional success callback, and optional dataType. Since jQuery 1.12 you can also pass a settings object: $.get({ url, data, dataType }). It returns a jqXHR for .done() / .fail() / .always().
A jqXHR object — a Promise-like wrapper around the request. Chain .done(fn) for success, .fail(fn) for errors, and .always(fn) for either outcome. Call jqXHR.abort() to cancel an in-flight GET.
$.get() is sugar for $.ajax({ url, data, success, dataType }) with type GET. Use $.get() for simple reads. Use $.ajax() when you need full control: custom headers, beforeSend, global: false, or other advanced settings.
function(data, textStatus, jqXHR). data is the parsed body; textStatus is usually "success"; jqXHR is the same object $.get() returned. For JSONP / some cross-domain GETs, jqXHR and textStatus may be undefined.
Yes. On HTTP or network errors the success callback never runs, and nothing alerts you unless you chain .fail(), use .always(), or listen for the global ajaxError event. Always handle failures when the user needs feedback.
Use $.get() to read data (query params in the URL). Use $.post() to send body data — form submits, creates, and other write operations. Both are shorthands over $.ajax().

Next: jQuery.post()

Send data in the request body with the POST shorthand.

$.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.

9 people found this page helpful