jquery插件之定时查询待处理任务数量
使用方法:
代码如下:
$("#todo_tip").pull_todo_count();
后台返回值
代码如下:
{"todo_count":3}
js文件
代码如下:
(function ($) { var element; $.fn.pull_todo_count = function () { var a = $('<a>0个审核待申请</a>'); a.attr("href","/process/todo_list"); a.appendTo($(this)); $(this).hide(); element = $(this); timerRequestData(); }; function timerRequestData() { $.ajax({ url:'/pull_todo_count', type:'get', data:null, dataType:'json', success:function(data){ var count = data["todo_count"]; console.log(count); if(count > 0){ element.children("a").html(count+"个审核待申请"); element.show(); }else{ element.hide(); } } }); setTimeout(timerRequestData,60000); } })(jQuery);
模板html代码
代码如下:
{% if user.is_authenticated %} <span id="todo_tip" style="display: none;"></span> {% endif %}
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17