Created
August 10, 2017 15:00
-
-
Save osw4l/a22b73eb5fd59f16fc303b52c76e56b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment