Skip to content

Instantly share code, notes, and snippets.

@bittersweetryan
Created August 1, 2012 21:29
Show Gist options
  • Save bittersweetryan/3230929 to your computer and use it in GitHub Desktop.
Save bittersweetryan/3230929 to your computer and use it in GitHub Desktop.
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