Created
August 25, 2015 17:54
-
-
Save omoshetech-t/55f2ec71eb64a2d7468d to your computer and use it in GitHub Desktop.
Example of Callback Hell with Ext JS.
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
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