V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2019-12-25 02:34:21 +08:00 · 3761 次点击
    这是一个创建于 1578 天前的主题,其中的信息可能已经有所发展或是发生改变。
    因为不熟悉 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 条回复    2019-12-25 15:08:46 +08:00
    KasuganoSoras
        1
    KasuganoSoras  
       2019-12-25 03:21:13 +08:00   ❤️ 4
    RV0n
        2
    RV0n  
       2019-12-25 08:37:46 +08:00
    是 ajax 不是 ajxa
    tyhuohuo8
        3
    tyhuohuo8  
       2019-12-25 10:50:29 +08:00
    @KasuganoSoras 闷声发财可还行
    slamJay
        4
    slamJay  
       2019-12-25 14:54:53 +08:00
    @KasuganoSoras 闷声发大财 学习了
    boyzhh
        5
    boyzhh  
    OP
       2019-12-25 15:08:18 +08:00
    @KasuganoSoras 万分感谢
    boyzhh
        6
    boyzhh  
    OP
       2019-12-25 15:08:46 +08:00
    @RV0n 看出来了我确实不太熟悉 /尴尬
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   863 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:34 · PVG 05:34 · LAX 14:34 · JFK 17:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.