推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
yuoboo
V2EX  ›  Python

如何实现返回上一页页面不刷新?场景如下!

  •  
  •   yuoboo · Sep 7, 2018 · 4592 views
    This topic created in 2943 days ago, the information mentioned may be changed or developed.
    页面中有三个下拉菜单,选择下拉菜单后通过 ajax 将选择内容加载到页面,

    问题:现在页面有其他跳转,跳转后再次返回上一页(也就是下拉菜单页时),页面刷新,每次都需要重新选

    如何能实现再次返回时,页面显示与跳转之前相同?

    来,调教吧!
    4 replies  •  2018-09-07 22:10:18 +08:00
    a62527776a
        1
    a62527776a  
       Sep 7, 2018   ❤️ 1
    存 storage 设过期时间
    jinggoing
        2
    jinggoing  
       Sep 7, 2018   ❤️ 1
    把下拉菜单的选项数据保存到 localstore 对象,每次进入页面时读一下 没有就用默认的
    qile1
        3
    qile1  
       Sep 7, 2018 via Android
    这个和 Python 好像没关系吧,难道你是使用 django 或者 flask,那你跳转时候获取选择数据,返回时候通过模板程序赋值不知道可以比,如果是点浏览器后退按钮,好像不刷新就不好弄
    xpresslink
        4
    xpresslink  
       Sep 7, 2018
    学习一下前端框架,比如 react,vue 之类的,做成单页面应用。
    最简单的是使用 bootstrap 模态框 一个页面里建 3 个弹层.

    用原始一些的办法,就是把数据放 session 里或 cookie 里,返回时恢复。 用 input type=hidden 也可以把数据带回来。
    总之办法多了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1225 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 23:43 · PVG 07:43 · LAX 16:43 · JFK 19:43
    ♥ Do have faith in what you're doing.