var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200) {
//do stuff to your dom, JSON.parse(return stuff) etc.
}
}
xhr.open("POST", "/some route/" + whatever, true);
xhr.send();
FormData(); would add 2 more lines to the above...
I see no point in all this front-end toolchain stuff trying to maintain an illusion that ES6 runs in most browsers.
Invariably maintaining false abstractions will not promote deeper understandings of the rather essential and basic "request response" cycle of HTTP.It's not even pretty. Classes in JS? Gimme a break. Show me the ugly truth and K.I.S.S. because life is short and we have better things to do in life...
So are you saying that most projects that use JS should avoid the use of ES6?
While Ruby is pretty and all, I don't find that I'm enjoying the lie that is ES6, and don't even get me started on classes in JS, etc.
Bottom line, JS isn't my favorite language, but I'm not dying reading/writing ES5, (nor does ES6 look lovely when I know that it's lying to me) and the advantages outweigh the disadvantages...
I'm questioning a lot of the group-think decisions.
State management? What is "a variable"?
Many times the cure is worse than the disease...