Hacker News new | ask | show | jobs
by Klonoar 1927 days ago
I don't have anything against jQuery, but isn't it a bit weird to have that be the example in 2020? Wouldn't `fetch` just work fine there...?
4 comments

I'd happily accept a PR to the docs! I launched this service in... 2012
This is what I love about HN and puts a smile on my face every damn time.

For some reason, it makes the whole internet with its billions of users feel so small, for a sharp and brief moment.

Of course we live in our own bubble on HN, so it's quite a specific and targeted demographic already, but still.

Well, now I look like an ass. :)

I was assuming this was a new thing - my mistake! Makes much more sense now, haha.

Now you have one! (I fixed a typo and added a note about the presence of a CORS header on responses, too.)
jQuery is still used on a huge number of sites.

> jQuery alone is found on nearly 85% of the mobile pages tracked by HTTP Archive

https://almanac.httparchive.org/en/2020/javascript#what-do-w...

Yes but it’s worth mentioning that jQuery Ajax is a high-level API while `fetch` is a low-level method. The default call is sometimes (most of the times?) not what you want, and you have to add one or more options.
It's not any more complicated to use than $.ajax ever was; the major difference is that it returns promises by default instead of needing callbacks, and that's a strict improvement.

That said, I'm glad you gave me a reason to look at the jQuery docs again, for the first time in years. What a 2009 mood!

edit: And if I'd looked more closely, I'd have seen that $.ajax now does return a promise. So that's good! Still appreciate the nostalgia hit.

TIL!