dongqing904999 2015-06-04 14:52
浏览 21

Jquery每秒刷新选择列表

I am working on an e-commerce project and I would like to set up 2 dropdown lists linked in ajax. The first list contains the products and the second one contains the quantity of each product.

There is a problem when a user selects a product and then a quantity, and, in the same time another user selects a product and then a quantity => the quantities are not correct. I will try to explain what I mean.

Imagine a first product named "A" with 2 quantities. A first user choses this product and selects 1 quantity. there is one quantity left for this product. At this same very moment, if another user selects the same product, the quantities show "2" ! It is difficult to explain but I wonder if a timeout function should fix this.

  • 写回答

1条回答 默认 最新

  • dongteng2534 2015-06-04 15:16
    关注

    You could use setTimeout to update the quantity drop down items every so often based on the product the user has currently selected however I think this a bit overkill.

    You would also have to set and store on the server the quantity values every time the user changed their selection.

    It is do-able but I would just re-validate the quantity the user has selected is still available once they submit the form.

    评论

报告相同问题?

悬赏问题

  • ¥15 Fluent udf 编写问题
  • ¥15 求合并两个字节流VB6代码
  • ¥15 Pyqt 如何正确的关掉Qthread,并且释放其中的锁?
  • ¥30 网站服务器通过node.js部署了一个项目!前端访问失败
  • ¥15 WPS访问权限不足怎么解决
  • ¥15 java幂等控制问题
  • ¥15 海湾GST-DJ-N500
  • ¥15 氧化掩蔽层与注入条件关系
  • ¥15 Django DRF 如何反序列化得到Python对象类型数据
  • ¥15 多数据源与Hystrix的冲突