7 ms·
The Ajax section is just not good enough. The main reason I still use jQuery is that they unify their promise type with their ajax. It's easy to create code th
by gnud 11y ago
The Ajax section is just not good enough.
The main reason I still use jQuery is that they unify their promise type with their ajax. It's easy to create code that works with any promise, ajax or otherwise.
- couchand 11y agoIt would be trivial to convert the callback-based method to a promises one in whichever library you're using. For instance, with bluebird[0]: d3.json = require('bluebird').promisify(d3.json); [0]: https://github.com/petkaantonov/bluebird https://github.com/petkaantonov/bluebird
- acconrad 11y agoYou should try reqwest if all you need jQuery for is AJAX
- gnud 11y agoA good ajax library that's well integrated with a good promise library, that's completely cross-browser, back to IE7.
- candu 11y agoIt's easy enough (as others have mentioned) to wrap d3.xhr() in a promise. I actually like that d3 uses callbacks here, leaving async control flow concerns to other libraries. No, my main quibble here is that d3.xhr() is still short on convenience and flexibility as compared to $.ajax(). (For instance: you have to build GET URLs manually? No .contentType() as a shorthand for the header? No automatic JSON.stringify() when POSTing application/json data? No HTTP basic auth support? etc.)