Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jQuery.get() 4.0 backward compatibility issue #5426

Open
hugodevreugd opened this issue Mar 1, 2024 · 3 comments
Open

jQuery.get() 4.0 backward compatibility issue #5426

hugodevreugd opened this issue Mar 1, 2024 · 3 comments
Labels

Comments

@hugodevreugd
Copy link

The jQuery api describes jQuery.get as: jQuery.get( url [, data ] [, success ] [, dataType ] )].

In jQuery 3.5.7 this code, with null for the data parameter, works:

var jqxhr = $.get( "example.php", null, function() {
  alert( "success" );
});

In jQuery 4.0 this code doesn't work anymore, you have to remove the null parameter:

var jqxhr = $.get( "example.php", function() {
  alert( "success" );
});

A small change, but this breaks backward compatibility.

@dmethvin
Copy link
Member

dmethvin commented Mar 2, 2024

The docs don't say that you can use null for data, it's supposed to be an object or string. According to #5139 (comment) and the docs, null is used to omit the callback. The second example omits data without needing to mention it at all. Worth a mention in the upgrade guide though I guess?

@timmywil timmywil added the Docs label Mar 3, 2024
@timmywil
Copy link
Member

timmywil commented Mar 3, 2024

Thanks for the issue and thanks for pointing that out, Dave. We'll mention it in the upgrade guide.

@rexfactor
Copy link

rexfactor commented Apr 6, 2024

Has anyone here come across this error when using $.get() ? Also, I was using the hosted library served up by Google when I first got the message so I then loaded a local file of 3.6.

jquery-3.6.0.min.js:2 Uncaught TypeError: t.call is not a function
at Function.each (jquery-3.6.0.min.js:2:3003)
at S.fn.init.each (jquery-3.6.0.min.js:2:1481)
at Object.success ((index):21:15)
at c (jquery-3.6.0.min.js:2:28327)
at Object.fireWith [as resolveWith] (jquery-3.6.0.min.js:2:29072)
at l (jquery-3.6.0.min.js:2:79901)
at XMLHttpRequest. (jquery-3.6.0.min.js:2:82355)

NOTE: I was testing using localhost when I got this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants