Nowadays you'd use fetch anyway which would reduce that code to not much more than the jQuery samples.
That is, if you don't need to support IE (And I feel like we're finally in the phase where it slowly, but steadily dies off). Otherwise you can ponyfill it.