回发后级联下拉列表为空

发布于 2024-09-19 18:05:57 字数 182 浏览 4 评论 0原文

表单包含 2 个级联下拉菜单。当在第一个下拉列表中选择一个项目时,jQuery 从服务器检索列表 (json) 并填充第二个下拉列表。

用户将页面发布到服务器,当页面返回时,下拉列表为空,因为它没有存储在视图状态中。

在这种情况下你会怎么做?这是使用 jQuery 级联下拉菜单并尝试使页面更加无状态变得乏味的地方吗?

A form contains 2 cascading dropdowns. When an item is selected in the first dropdown, jQuery retrieves a list (json) from the server and fills the 2nd dropdown.

The user posts the page to the server, and when the page is returned the dropdown is empty because its not stored in viewstate.

What do you do in this situation? Is this the point where cascading dropdowns using jQuery and trying to make your page a little more stateless gets tedious?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

庆幸我还是我 2024-09-26 18:05:57

您始终可以将其设置为在页面加载时从服务器提取 json,假设第一个下拉列表已选择一个项目。如果您知道第一个下拉列表有值,另一个选项是在服务器端预填充第二个下拉列表。

You could always just set it up to pull the json from the server on page load as well, assuming that the first dropdown list has an item selected. The other option would be to pre-fill the second dropdown server-side if you know that the first dropdown has a value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文