Created
August 1, 2012 21:29
-
-
Save bittersweetryan/3230929 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 getMessages(name){ | |
return $.Deferred(function(dfd){ | |
var messages = []; | |
// static messages | |
messages.push("Hello " + name); | |
messages.push("Thank you for stopping by."); | |
// call our api to get another message | |
$.ajax({ | |
url: 'API.cfc', | |
type: 'post', | |
data: { | |
method : 'sayGoodbye', | |
name : name, | |
returnFormat: 'JSON' | |
}, | |
success: function(data){ | |
messages.push(JSON.parse(data)); | |
dfd.resolve(); | |
}, | |
error: function(){ | |
dfd.reject(); | |
} | |
}); | |
}).promise(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment