根据所选国家/地区在全球网站上显示郊区的最佳实践
假设来自全球网站的用户从下拉列表中选择他/她的国家/地区。我想向用户展示该国家/地区的郊区列表。
我发现的问题是,用国家/地区-郊区关系填充 SQL 数据库可能需要大量工作。完成此操作后,我想每个用户都必须从数据库动态加载郊区列表,而数据库的扩展性不太好。
另一种方法是使用 JavaScript 并对郊区进行硬编码,以便在选择国家/地区时显示它们。每次我进入一个新的乡村市场时,这种方式似乎也需要做很多工作,而且我必须进入数千个郊区。
我不久前见过一些Web服务,它似乎能够完成这项工作(我不记得链接了)。根据所选国家/地区动态列出郊区的最佳做法是什么?
Let's say a user from a global site selects his/her country from a drop down list. I would like to present the user with a list of suburbs of that country.
The problem I find is that it may be a lot of work populating the SQL database with country-suburb relations. And having done that, I would imagine each user would have to load the list of suburbs dynamically from the database which doesn't scale too well.
Another way is to use JavaScript and hard code the suburbs so they come up when the country is selected. Again this way seems like a lot of work too each time I enter a new country market, and I've to have thousands of suburb entered.
I've seen some Web Service a while ago which seems to be able to do the job (I can't remember the link). What is the best practice to list the suburbs dynamically based on the country selected?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将主配对保留在数据库中,然后将每个国家/地区推送到 JSON 文件(可能在 CDN 上),该文件会动态加载并在选择国家/地区时填充您的选择字段。每当您对数据库进行更改时,请重新推送相应的 JSON 文件。
Keep the master pairings in your database, but then push each country out to a JSON file (possibly on your CDN) that gets loaded dynamically and populates your select field whenever a country is chosen. Whenever you make a change in your database, re-push the respective JSON file.