Skip to content

Instantly share code, notes, and snippets.

@alexcurtis
Created February 23, 2013 13:17
Show Gist options
  • Save alexcurtis/5019692 to your computer and use it in GitHub Desktop.
Save alexcurtis/5019692 to your computer and use it in GitHub Desktop.
Before JQuery Promises Refactoring
//Get Services For id
function GetServices(id) {
//Get Popular Services
var popularServiceUrl = PopularServiceUrl(id);
$.getJSON(popularServiceUrl, {}, function (data) {
var pservices = {};
var services = {};
$(data).each(function() {
CreatePopularService(this, function(service) {
//...
});
});
//Get Category Services
var categoryServiceUrl = CategoryServiceUrl(id);
$.getJSON(categoryServiceUrl, {}, function (data) {
$(data).each(function () {
CreateService(this, function(service) {
//...
});
});
PostProcessService(pservices);
PostProcessService(services);
ShowResults();
}).error(function () { ShowErrorDialog(); });
}).error(function () { ShowErrorDialog(); });
}
function PostProcessService(service) {
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment