case 'result':
print_r(count($_SESSION['tests']));
break;
case 'set':
print_r($_SESSION['tests']['param_' . $_POST['name']] = 1);
break;
default:
$_SESSION['tests'] = [];
print_r('
<script src="//code.jquery.com/jquery-1.11.3.js"></script>
<script>
$(document).ready(function() {
const deferreds = [];
for (let i = 0; i < 100; ++i) {
let promise = $.ajax({
type: "post",
url: window.location.href,
dataType: "json",
data: {
name: i,
cmd: "set",
},
});
deferreds.push(promise);
}
$.when(...deferreds)
.done(function() {
window.location = [
window.location.href,
window.location.href.match(/\?/) ? "&" : "?",
"cmd=result",
].join("");
});
});
</script>
');
break;
}
этим кодом
Обсуждают сегодня