Home  >  Article  >  Web Front-end  >  jquery plug-in regularly queries the number of pending tasks_jquery

jquery plug-in regularly queries the number of pending tasks_jquery

WBOY
WBOYOriginal
2016-05-16 16:50:221224browse

Usage:

Copy code The code is as follows:

$("#todo_tip" ).pull_todo_count();

Background return value

Copy code The code is as follows:

{"todo_count":3 }

js file

Copy code The code is as follows:

(function ($) {
var element;
$.fn.pull_todo_count = function () {
var a = $('0 pending applications');
a.attr("href", "/process/todo_list");
a.appendTo($(this));
$(this).hide();
element = $(this);
timerRequestData();
};
function timerRequestData() {
$.ajax({
} url:'/pull_todo_count',
type:'get',
data:nu ll,
dataType:'json',
success:function(data){
var count = data["todo_count"];
console.log(count);
if(count > 0){
                                                                                                                                                                                                           .        element.hide();
}
                                                                                                                                                                    
Template html code





Copy code
The code is as follows:

{% if user.is_authenticated %}

< ;span id="todo_tip" style="display: none;"> {% endif %}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn