Your code is fine for this use case. But I'd have to bite my nails hoping it would work on browser 'X' for other use cases, which is simply not worth the headache. Cross browser compatibility is a real pain, you know? For me JQuery does it very well.
And good luck using your new ajax function :)
Drop support for old IE browsers, why are people still trying to fight to support them. I agree with the blog post, one day people will finally drop support for non-HTML5 browsers (IE8 and below) and they will see how easy it is to write clear, short native code that works fine in all browsers.
It will take time though as many people aren't even familiar with the native APIs.
You want to know why people worry about older versions of IE? Because a large enough chunk of their visitors still use those browsers. It's that simple.
$.get('test.html', function(r) {
window.document.body.className += " done";
});
But: This is not about short code. It's about readability. What's readyState 4? Why "open" a request before sending it?It gets even messier when you find out one day you have to handle failures, or serialize data to send to that endpoint, or get notified on network events, or cancel an ongoing request, or etc etc etc.
Re:Why It's Time to Sunset jQuery
by grannyg00se on Sunday April 14, 2013 @04:55PM
(#5548262)
My code is a response to neya's comment. It's not about short code or readability. It's about demonstrating that neya's example has completely unreasonable non-jQuery code given the jQuery code it is being compared against.
without jQuery: http://browsershots.org/http://evening-harbor-8654.herokuapp...
with jQuery: http://browsershots.org/http://evening-harbor-8654.herokuapp...