How to use:
Copy Code code as follows:
$ ("#todo_tip"). Pull_todo_count ();
Background return value
Copy Code code as follows:
JS file
Copy Code code as follows:
(function ($) {
var element;
$.fn.pull_todo_count = function () {
var a = $ (' <a>0 pending Application </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+ "an audit pending application");
Element.show ();
}else{
Element.hide ();
}
}
});
SetTimeout (timerrequestdata,60000);
}
}) (JQuery);
Template HTML code
Copy Code code as follows:
{% if user.is_authenticated%}
<span id= "Todo_tip" style= "Display:none;" ></span>
{% ENDIF%}