前言:
现时大家对“js递归循环”可能比较重视,你们都想要分析一些“js递归循环”的相关文章。那么小编也在网摘上网罗了一些关于“js递归循环””的相关内容,希望我们能喜欢,你们快快来学习一下吧!视频加载中...
//ajax获取post后端数据
function ajxpostdata(business, url, Npeople) {
let data = {}
if (Npeople == "undefined") {
data = {
businessname: business,
}
} else {
data = {
businessname: business,
Npeoplename: Npeople
}
}
let ajxpostdata = new XMLHttpRequest();
ajxpostdata.open('POST', url, true);
ajxpostdata.onreadystatechange = function () {
if (ajxpostdata.readyState == 4) {
if (ajxpostdata.status == 200) {
if (JSON.parse(ajxpostdata.responseText)['data1']) {
obtain(JSON.parse(ajxpostdata.responseText)['data1']);
}
AA.numberofpeople(JSON.parse(ajxpostdata.responseText)['data']);
}
}
}
ajxpostdata.send(JSON.stringify(data));
}
//递归函数
function obtain() {
if (document.getElementById('select02') && document.getElementById('div02')) {
document.getElementById('select02').remove();
document.getElementById('div02').remove();
}
let url = ';;
let arr01 = [];
let arr02 = [];
let arr05 = [];
let content = (Array.prototype.shift.apply(arguments));
let arr = ['同意', '拒绝'];
for (let i = 0; i < content.length; i++) {
let num = Math.floor(Math.random() * 2)
content[i]['confirm'] = arr[num];
arr01.push(content[i]);
}
for (let i = 0; i < arr01.length; i++) {
if (arr01[i]['confirm'] == '拒绝') {
arr02.push(arr01[i]['id']);
arr05.push(arr01[i])
} else {
arr06.push(arr01[i])
}
}
let number = arr02.length;
if (arr02.length == 0) {
return
} else {
ajxpostdata(number, url, arr05);
}
contentdisplay()
}
标签: #js递归循环