Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. function ajax(options) {
  2. return new Promise(function (resolve, reject) {
  3. $.ajax(options).done(resolve).fail(reject);
  4. });
  5. }
  6.  
  7. then run:
  8.  
  9. ajax({
  10. url: YOUR_URL,
  11. type: 'post',
  12. dataType: 'json',
  13. data: {
  14. action: some_action,
  15. action_2: another_action
  16. }
  17. }).then(
  18. function fulfillHandler(data) {
  19. // callback
  20. }
  21. ).catch(function errorHandler(error) {
  22. // error
  23. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement