5 ms·
Ajax is the last thing keeping me in jquery.
by recursive 10y ago
Ajax is the last thing keeping me in jquery.
- rnnr 10y agoare you aware of html5 fetch? It suffices most of the time but again not compete replacement(if you want to get xml for example)
- recursive 10y agoYes, I'm aware of it. Support is not good.
- sotojuan 10y agohttps://github.com/mzabriskie/axios https://github.com/mzabriskie/axios https://github.com/github/fetch 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.
- overcast 10y agoFrom my original link above. http://youmightnotneedjquery.com/ 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/ https://vuejs.org/ combined with https://github.com/vuejs/vue-resource https://github.com/vuejs/vue-resource is currently my fave.
- jukkakoskinen 10y agoYou're mistaken, Vue doesn't provide any XHR helpers. Look into fetch or superagent, if you need an abstraction.
- overcast 10y agohttps://github.com/vuejs/vue-resource https://github.com/vuejs/vue-resource is what you use.
- bnt 10y agoGlad 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.
- overcast 10y agoyes, vue-resource is what I use. Works well.
- NDizzle 10y agoYou don't need jquery!!! You need... these other things that fewer people use and/or care about. Just use jQuery. Please.
- overcast 10y agoYou 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.
- NDizzle 10y agoI 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.
- joobus 10y agojquery-3.1.0.min.js is 84k. vue.min.js is 75k. vue-resource.min.js is 13k. So jquery is smaller.
- overcast 10y agojQuery 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.