aboutsummaryrefslogtreecommitdiffstats
path: root/src/ajax.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2022-10-17 18:54:28 +0200
committerGitHub <noreply@github.com>2022-10-17 18:54:28 +0200
commit74978b7e892537559850cda7332bdab8106e6354 (patch)
tree2c63c07e58a59a14b0f11bf0387f6aad7fa7ca88 /src/ajax.js
parent8c7da22caeae8c2c3f7e9869d5f47414669f106c (diff)
downloadjquery-74978b7e892537559850cda7332bdab8106e6354.tar.gz
jquery-74978b7e892537559850cda7332bdab8106e6354.zip
Ajax: Support `null` as success functions in `jQuery.get`
According to the docs, one can use `null` as a success function in `jQuery.get` of `jQuery.post` so the following: ```js await jQuery.get( "https://httpbin.org/json", null, "text" ) ``` should get the text result. However, this shortcut hasn't been working so far. Fixes gh-4989 Closes gh-5139
Diffstat (limited to 'src/ajax.js')
-rw-r--r--src/ajax.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/ajax.js b/src/ajax.js
index dc9fb242b..36a9c9b57 100644
--- a/src/ajax.js
+++ b/src/ajax.js
@@ -846,8 +846,9 @@ jQuery.extend( {
jQuery.each( [ "get", "post" ], function( _i, method ) {
jQuery[ method ] = function( url, data, callback, type ) {
- // Shift arguments if data argument was omitted
- if ( typeof data === "function" ) {
+ // Shift arguments if data argument was omitted.
+ // Handle the null callback placeholder.
+ if ( typeof data === "function" || data === null ) {
type = type || callback;
callback = data;
data = undefined;