jQuery .get() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Ajax

Definition

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().

Syntax

Start with these common calls. Keep them short and readable.

jQuery
// 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)
CallWhat it does
jQueryLearn jQuery.get(): the GET shorthand for $.ajax(), url/data/success/dataType signatures, settings object since 1.12, jqXHR .done()/.fail()/.always(), dataType json, silent errors, and how it compares to $.ajax() and $.post().

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Call $.get(url) or $.get(url, data, success, dataType).
Step 2Or pass a settings object: $.get({ url, data, dataType }).
Step 3Chain .done() / .fail() / .always() on the jqXHR (preferred over relying only on the success argument).

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

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.

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.

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

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() Method

Send data in the request body with the POST shorthand.

jQuery.post() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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