【发布时间】:2018-05-02 18:31:37
【问题描述】:
我正在尝试将 100 000 个项目加载到按钮单击事件的下拉列表中。但是加载太慢了。如何减少物品的加载时间?
产品循环
for (int i = 0; i < 100000; i++) {
out.print("<option>Product" + i + "</option>");
}
阿贾克斯
<script>
function getproduct() {
var output;
var xhtp = new XMLHttpRequest();
xhtp.onreadystatechange = function () {
if (xhtp.readyState === 4 && xhtp.status === 200)
output = output +xhtp.responseText;
}
}
document.getElementById("product").innerHTML = output;
}
xhtp.open("post", "ProductController", true);
xhtp.send();
}
</script>
【问题讨论】:
-
你应该考虑使用数据库,或者看看 reactjs