推荐学习书目
› 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
boyzhh
V2EX  ›  Python

求一段 ajxa 代码 /害羞

  •  
  •   boyzhh · Dec 25, 2019 · 5060 views
    This topic created in 2467 days ago, the information mentioned may be changed or developed.
    因为不熟悉 ajxa,求一段代码,需求是这样的:
    django 中的 base 模板中
    1,载入页面时判断 session['waiting']如果>0(因为可能有多个项目取数据,几个项目就是数字几)进行 2
    如果 session['waiting']=0,以下都不显示
    2,每 2 秒刷新请求: https://xx.xx.xx.xx/xxxxxx/
    3,如果返回值{'new_msg': 2(完成几个显示数字几), 'waiting':数字}'new_msg>0,更新一个通知<div id=info> 的内容为“计算完成[数字],点我查看”
    4,如果返回值 waiting=0,停止刷新,waiting>0 就是还有没完成的,继续刷新
    5,切换页面就等于循环第一步,session 的 waiting 值是在后台刷新

    其实就是用 celery 异步去取了一系列数据,因为是并行的,直到全都取完才可以计算结果,计算完了给网页的通知栏发个通知告诉用户计算完毕。

    1 用 django 模板会写,就是判断一下 session 值,2,3,4 不会写,jquery 那些不了解啊,谢谢高手们
    6 replies  •  2019-12-25 15:08:46 +08:00
    KasuganoSoras
        1
    KasuganoSoras  
       Dec 25, 2019   ❤️ 4
    RV0n
        2
    RV0n  
       Dec 25, 2019
    是 ajax 不是 ajxa
    tyhuohuo8
        3
    tyhuohuo8  
       Dec 25, 2019
    @KasuganoSoras 闷声发财可还行
    slamJay
        4
    slamJay  
       Dec 25, 2019
    @KasuganoSoras 闷声发大财 学习了
    boyzhh
        5
    boyzhh  
    OP
       Dec 25, 2019
    @KasuganoSoras 万分感谢
    boyzhh
        6
    boyzhh  
    OP
       Dec 25, 2019
    @RV0n 看出来了我确实不太熟悉 /尴尬
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   858 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 22:31 · PVG 06:31 · LAX 15:31 · JFK 18:31
    ♥ Do have faith in what you're doing.