0

我现在正在开发包含印度尼西亚 70,000 多个村庄的 javascript 库(可在http://bisbak.com/regina/访问),并且我构建了一个数据浏览器小部件。在 Safari 和 Firefox 中一切正常。但是在使用 Chrome 时,当我碰巧选择一个地区(自动加载村庄)时,总是需要很长时间。检索地区村庄的代码如下:

for (n in data) {
  var rs = [];
  if (n is ok) rs.push(data[n]);
  return rs;
}

数据是具有 70,000 多个村庄钥匙的 json 对象。

4

1 回答 1

0

也许您应该仅在必要时加载数据。

在您的情况下,您只能在启动时加载Provinsi 。And when one Provinsi item is selected, you only load all Kab./Kota items that belong to it; and when one Kab./Kota item is selected, you only all Kecamatan items that belong to it, and so on.

为了提高性能,您可以加载两个级别而不是一个级别。So when a Provinsi item is selected, you load all Kab./Kota items and the Kecamatan that belong to it. 此外,在客户端和服务器端缓存数据。

于 2010-09-03T12:50:20.787 回答