5 ms·
JQuery Core 1.9 Upgrade Guide
- jasonkostempski 14y ago"Prior to 1.9, an ajax call that expected a return data type of JSON or JSONP would consider a return value of an empty string to be a success case, but return a null to the success handler or promise. As of 1.9, an empty string returned for JSON data is considered to be malformed JSON (because it is); this will now throw an error." That one is gonna cause some headaches, I've abused this behavior for years, as recently as yesterday.
- dmethvin 14y agoSo your server returns an HTTP 200 with an empty response, and you process the `null` in your success handler? Do you really want a `null` returned? Is this a server you control, or is it some third-party service? Just curious about the use case and how widespread it might be.
- jasonkostempski 14y agoI was probably in control of all of them at some level but I either didn't think about it or didn't care enough. Sometimes I suck. Today I can start sucking a little less.
- k3n 14y agoIt sounds like you knew it was bad practice, and yet you did it anyways...?
- svachalek 14y agoThis confused me for a minute but I think I get it now -- it's referring to a response with zero length, not a response of two quote characters right?
- jasonkostempski 14y agoYes, but two quote characters on their own isn't valid JSON either so that'll error too, though I assume it already did.
- deltasquared 14y agoThis stuff never works happily. I don't really trust jQuery to handle JSON/JSONP properly. It is easy enough to drop back down to calling XMLHttpRequest by hand. Sample code is here, and changes to jQuery won't break it: http://stackoverflow.com/questions/5395118/jquery-1-5-json-error-invalid-label/5403755#5403755 http://stackoverflow.com/questions/5395118/jquery-1-5-json-e...
- kamjam 14y agoWhy did you not just specify the dataType in your ajax call? http://api.jquery.com/jQuery.ajax/#data-types http://api.jquery.com/jQuery.ajax/#data-types
- deltasquared 14y agoBecause was working with jQuery 1.5, and data-types showed up in 1.5.1
- lacosaes0 14y agoIf you're not targeting old browsers there's no reason to use JQuery. Plain JavaScript offers you the same features.
- joshuacc 14y agoIf by "features" you mean the ability to achieve the same result... Well, obviously. However, jQuery's main feature is having a nice interface that is much more consistent and usable than many of the native APIs. The "fluent interface" or "method chaining" style is especially nice.
- robin_reala 14y agoThis is true for a lot of apps and functionality, but you’re ignoring the large library of jQuery plugins out there. Just as a basic example I needed a slider on a recent app I built. Sure, there’s <input type="range"> but if you want it to work in IE or Firefox you’re better off dropping in a jQuery UI Slider.
- Yaggo 14y agoThe beauty is that <input type="range"> works in any browser. Some just render it as text input.
- robin_reala 14y agoA fair point for a standard form, but try telling Firefox and IE users that they have to type in their audio volume manually on the jukebox I built.
- benesch 14y agoI'm certainly not a jQuery fanboy, but jQuery's DOM-manipulation functions are certainly more concise and abstract away some of the funky internals (NodeLists, etc.). That said, I've always found jQuery's function naming to be particularly ambiguous. There's no indication that "find" searches an element's descendants for a matching CSS selector based on its name. On the other hand, vanilla JS's element.getElementsByTagName is so much more verbose. Back in the day I found PrototypeJS [0] to be much better organized and offer the same feature set, but it's largely fallen out of use since Rails dropped it. mootools is nice but the docs, while comprehensive, are arranged in no logical order. Every time I try to pick up mootools I end up running around the docs in circles. tl;dr jQuery is overblown but I think there's room for improvement over vanilla JS. Plus there's always the (literally) hundreds of plugins for every possible application of jQuery. [0] http://prototypejs.org http://prototypejs.org
- thiderman 14y agoSince so very very many things changed in backwards incompatible ways, why didn't they just go with calling it 2.0 rather than 1.9? I mean, the changes are huge and most versioning schemes increase the major version number on backwards incompatibility.
- zalew 14y agobecause 2.0 will be 1.9 with dropped <ie9 support. jQuery 2.0 (early 2013, not long after 1.9): This version will support the same APIs as jQuery 1.9 does, but removes support for IE 6/7/8 oddities such as borked event model, IE7 “attroperties”, HTML5 shims, etc. Our goal is for 1.9 and 2.0 to be interchangeable as far as the API set they support. When 2.0 comes out, your decision on which version to choose should be as simple as this: If you need IE 6/7/8 support, choose 1.9; otherwise you can use either 1.9 or 2.0. http://blog.jquery.com/2012/06/28/jquery-core-version-1-9-and-beyond/ http://blog.jquery.com/2012/06/28/jquery-core-version-1-9-an...
- dmethvin 14y ago> so very very many things changed in backwards incompatible ways jQuery has always made feature changes/additions on .x releases. We're saving the 2.0 moniker for removing oldIE because that is a much more significant change than these API cleanups. At this point the jQuery installed base is so big that any change, however innocuous, is a breaking change for someone. Even fixing bugs, conforming to W3C standards, or making API return values consistent can cause trouble because someone depends on the old way of doing things. We try to be respectful of people's existing work but also want to make forward progress. Like the intro at the top of the upgrade guide page says, this list seems a lot more scary than it really is. We're just trying to call out every change that we think may cause issues, so people can assess and address them in advance. The jQuery Migrate plugin is designed to make it easier to find any compatibility problems, and can be included with jQuery versions as old as 1.6. Add the plugin to your current code, run it, and view the console to see if there are warnings.
- malandrew 14y agoThere is nothing I would love to see more than for jQuery 2.0 to be modularized so people can pick and choose the modules they want/need. It would also be nice for them to adopt semantic versioning with 2.0. i.e. move to 2.0.0