News for hackers. Stuff that matters.
Re:JQuery++ by recursive on Friday August 05, 2016 @10:54AM (#12232755)
Ajax is the last thing keeping me in jquery.
Re:JQuery++ by sotojuan on Friday August 05, 2016 @10:57AM (#12232777)
https://github.com/mzabriskie/axios

https://github.com/github/fetch

Among countless others. Please don't bring in all of jQuery if you're just going to use one function from it.

Re:JQuery++ by overcast on Friday August 05, 2016 @10:59AM (#12232796)
From my original link above.

http://youmightnotneedjquery.com/

var request = new XMLHttpRequest(); request.open('GET', '/my/url', true);

request.onload = function() { if (request.status >= 200 && request.status < 400) { // Success! var data = JSON.parse(request.responseText); } else { // We reached our target server, but it returned an error

  }
};

request.onerror = function() { // There was a connection error of some sort };

request.send();

OR

Even better, you should just use a reactive front end framework. https://vuejs.org/ combined with https://github.com/vuejs/vue-resource is currently my fave.

Re:JQuery++ by NDizzle on Friday August 05, 2016 @11:11AM (#12232886)
You don't need jquery!!! You need... these other things that fewer people use and/or care about.

Just use jQuery. Please.

Re:JQuery++ by overcast on Friday August 05, 2016 @11:35AM (#12233091)
You don't need a reactive front end framework, but not using two way data binding at this point I think is crazy. Binding is an EXTREMELY powerful tool.
Re:JQuery++ by NDizzle on Friday August 05, 2016 @11:58AM (#12233297)
I have yet to see something that handles updates from other sources well. Meaning that the page the user is on is updated by some other person or process and those changes are propagated correctly. I still have events that fire when something is saved that check to see if it was modified while the user was in it.
Re:JQuery++ by joobus on Friday August 05, 2016 @11:49AM (#12233212)
jquery-3.1.0.min.js is 84k.

vue.min.js is 75k. vue-resource.min.js is 13k.

So jquery is smaller.

Re:JQuery++ by overcast on Friday August 05, 2016 @12:20PM (#12233512)
jQuery 3 also isn't doing reactive data binding, and is not compatible with older browsers. Not really a fair comparison, as they are meant for two different things. I just included it as a response to the AJAX stuff. If you're going to be doing AJAX, there is no reason not to use a modern front end framework.
Re:JQuery++ by bnt on Friday August 05, 2016 @11:04AM (#12232838)
Glad to see Vue mentioned :) However, Vue is just the view layer. If you want it to communicate with a server, I recommend looking into Vue-Resource.
Re:JQuery++ by overcast on Friday August 05, 2016 @11:13AM (#12232909)
yes, vue-resource is what I use. Works well.
Re:JQuery++ by jukkakoskinen on Friday August 05, 2016 @11:04AM (#12232837)
You're mistaken, Vue doesn't provide any XHR helpers. Look into fetch or superagent, if you need an abstraction.
Re:JQuery++ by overcast on Friday August 05, 2016 @11:14AM (#12232921)
Re:JQuery++ by rnnr on Friday August 05, 2016 @11:08AM (#12232862)
are you aware of html5 fetch? It suffices most of the time but again not compete replacement(if you want to get xml for example)
Re:JQuery++ by recursive on Friday August 05, 2016 @01:47PM (#12234335)
Yes, I'm aware of it. Support is not good.