javascript nested_promise_example.js
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript nested_promise_example.js相关的知识,希望对你有一定的参考价值。
getEmployeeSelectList(store, department_selected, position);
function getEmployeeSelectList(store, department_selected, position) {
getEmployeeListData(store, department_selected, position).then(function (response) {
console.log(response);
getListOfEmployees(response[0], response[1]).then(function(response) {
$('#employee_timeoff_list').html('');
console.log(response);
appendEmployeeList(response);
})
});
}
function getEmployeeListData(store, departmentSelected, position) {
return new Promise(function(resolve, reject) {
var storeArray = [];
(store === '5' ? storeArray.push('5', '51') : storeArray.push(store));
storeArray = JSON.stringify(storeArray);
if((departmentSelected === 9010 || departmentSelected === 9939) && position === 'GENERAL MANAGER') {
if(store !== '11') {
resolve(['getGeneralManagerList', {'store_numbers': storeArray}]);
}
else {
resolve(['getDivisionElevenList', {'department': departmentSelected, 'position': position}]);
}
}
else if(store === '11' || store === '12') {
if(departmentSelected === 8900 || departmentSelected === 8810) {
var list = '';
if(position === 'IT MANAGER') {
list = 'IT';
}
else {
list = "ALL";
}
resolve(['getCBOList', {'list': list}]);
}
else {
resolve(['getDivisionElevenList', {'department': departmentSelected, 'position': position}]);
}
}
else {
resolve(['getEmployeesByEmployeeCodes', {'employee_code_array': departmentSelected, 'store_numbers': storeArray}]);
}
});
}
function getListOfEmployees(url, array) {
return new Promise(function(resolve, reject) {
console.log(array);
$.post('employee_list/' + url, array, function (response) {
try {
response = JSON.parse(response);
var employeeList = response.data;
resolve(employeeList);
}
catch (error) {
reject(error);
}
});
});
}
以上是关于javascript nested_promise_example.js的主要内容,如果未能解决你的问题,请参考以下文章
javascript JavaScript isset()等效: - JavaScript
JavaScript 使用JavaScript更改CSS(JavaScript)
JavaScript之基础-1 JavaScript(概述基础语法)
前端基础-JavaScript的基本概述和语法
JavaScript
JavaScript