Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ajax(options) {
- return new Promise(function (resolve, reject) {
- $.ajax(options).done(resolve).fail(reject);
- });
- }
- then run:
- ajax({
- url: YOUR_URL,
- type: 'post',
- dataType: 'json',
- data: {
- action: some_action,
- action_2: another_action
- }
- }).then(
- function fulfillHandler(data) {
- // callback
- }
- ).catch(function errorHandler(error) {
- // error
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement