Skip to content

Instantly share code, notes, and snippets.

@omoshetech-t
Created August 25, 2015 17:54
Show Gist options
  • Save omoshetech-t/55f2ec71eb64a2d7468d to your computer and use it in GitHub Desktop.
Save omoshetech-t/55f2ec71eb64a2d7468d to your computer and use it in GitHub Desktop.
Example of Callback Hell with Ext JS.
Ext.Ajax.request({
url: 'hello.json',
success: function(response, opts) {
var hello = getMessage(response);
Ext.Ajax.request({
url: 'world.json',
success: function(response, opts) {
var world = getMessage(response);
Ext.Msg.alert('Success', hello + world);
},
failure: function(response, opts) {
var error = getMessage(response);
Ext.Msg.alert('Failure', error);
}
});
},
failure: function(response, opts) {
var error = getMessage(response);
Ext.Msg.alert('Failure', error);
}
});
function getMessage(response) {
var json = response.responseText;
return Ext.JSON.decode(json).message;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment