-
-
Save Denny966/79a831cd0dc307ac6f872bb8f22355a4 to your computer and use it in GitHub Desktop.
simple jQuery Deferred example
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 getData() { | |
const deferred = $.Deferred(); | |
API.ajax({ | |
url: [URL], | |
type: "GET", | |
dataType: "json", | |
headers: { | |
'Accept-Language': uiCulture | |
} | |
}).done((data: any) => { | |
deferred.resolve(data); | |
}).fail((data: any) => { | |
deferred.reject(data); | |
}); | |
return deferred.promise(); | |
} | |
getData().done(function(value) { | |
alert(value); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment