Q was designed to provide a robust way to provide you ways to write asynchronous code cleanly.
You can integrate the robustness of Q with jQuery promises.
- Exception handling
- Several additional methods give you deep control of the promise
- An error (or in a promise reject) in one chained thens will be handled “down the chain” by a later
Q with jQuery
When you pass in jQuery into Q, it coerces the jQuery promise into a Q promise that you can then use.
The following code snippet returns a Q promise from a jQuery AJAX or jQuery getJSON call.
You can continue to chain the promise and get all the goodness of Q.
- Understanding JQuery.Deferred and Promise
- Creating Responsive Applications Using jQuery Deferred and Promises
- Q on GitHub
- Promises A+ and Q