7 ms·
I've seen a bunch of these noJQuery posts lately, but they've always focused on selectors. I'm curious what these people use for Ajax. Do they use the (very v
by ben336 13y ago
I've seen a bunch of these noJQuery posts lately, but they've always focused on selectors. I'm curious what these people use for Ajax. Do they use the (very verbose) native syntax? Or are there any nice lighter weight libraries that separate out Ajax functionality into a readable abstraction like jQuery does?
- adventured 13y agoDefinitely a standard issue popularity backlash. See: PHP. Once something achieves overwhelming scale in tech, the majority turns on it because: dominance != cool.
- PavlovsCat 13y agoI use PHP without any shame, I even think MySQL might be just fine for me; but I also like raw JavaScript way too much to ever have bothered to use jQuery even once. That said, I have nothing against jQuery, but what used to annoy me was seeing Javascript questions being answered with jQuery snippets without anyone blinking, everywhere and all the time... you see, that's actually coming onto "my" turf and wantonly murdering there. That was too much, and if a "backlash" is needed to restore some sanity and balance, I say lash away.
- PavlovsCat 13y agoI like the part where someone else is making assumptions about anyone who isn't a jquery fan, I disagree based on the physical reality of my own existance, and some anonymous coward decides nah, I don't get to speak for myself, the one-sided blanket assumptions someone else pulled out of their ass are really all the "contribution" this "discussion" needs... oh well, thanks for the belly laugh ^^
- k3n 13y agoAre you thanking yourself for giving yourself a belly laugh?
- PavlovsCat 13y agoNo, whomever grayed my comment out because disagreeing in words would be too much like actual work.
- PavlovsCat 13y agoSo far, this has worked perfectly for me: function ajax(url, post_parameters, callback, data) { var http = new XMLHttpRequest(); if (http != undefined) { http.open(post_parameters == '' ? 'GET' : 'POST', url, true); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.onreadystatechange = function() { if (callback != null) { callback(this.readyState, this.status, this.responseText, data); // readyStates: UNSENT = 0, OPENED = 1, HEADERS_RECEIVED = 2, LOADING = 3, DONE = 4; } }; http.send(post_parameters); return true; } else { console.log("no ajax.. sorry."); return false; } }
- rmrfrmrf 13y agoDoesn't work in IE and doesn't support cross-domain requests. Oh, and yes, I'm sure every user knows to check their javascript console when an app does nothing.
- k3n 13y agoI wonder if that code block does anything at all. var http = new XMLHttpRequest(); if (http != undefined) { ... } In what runtime would calling this constructor return undefined (or null, or false...), and yet not throw an error?
- rmrfrmrf 13y agoYou're right, that code will blow up if the browser doesn't support XMLHttpRequest. The version below is more common: var ajaxObject; if (window.XMLHttpRequest) { ... } else if (window.ActiveXObject) { ... } if (ajaxObject) { ... } else { //handle users without ajax } and that's just to create the object! compare to: $.ajax();
- PavlovsCat 13y agoand that's just to create the object! compare to: $.ajax(); So you're comparing the body of one function to the signature of another? I know I posted some really shitty code, but you managed to shoot yourself in the foot even in that scenario, grats. https://github.com/jquery/jquery/blob/master/src/ajax.js https://github.com/jquery/jquery/blob/master/src/ajax.js Here, now it's apples to apples.
- randallsquared 13y agoYes: http://visionmedia.github.io/superagent/ http://visionmedia.github.io/superagent/