Created
June 23, 2014 18:37
-
-
Save kshyju/1de02464cb6b144f792d to your computer and use it in GitHub Desktop.
Nested ajax callbacks to make sure that we load look up data in all dropdowns before loading the page data.
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
//What is the alternative of getting rid of the nested callback hell ? | |
//Load the data for the 3 dropdowns | |
$http.get('Products/AllProducts/').success(function (data) { | |
$scope.products = data; | |
$http.get('Colors/AllColors/').success(function (colordata) { | |
$scope.colors = colordata; | |
$http.get('Products/AllSizes/').success(function (sizedata) { | |
$scope.sizes = sizedata; | |
// If this is an edit view, Load the saved data from db | |
if ($("#OrderId").length) { | |
$http.get('Orders/details?orderId=' + $("#OrderId").val()).success(function (orderData) { | |
$scope.formulaOperands = $scope.doSomeProcessingWithIds(orderData);; | |
}); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment