Try ERPNext Buy Support Partners Foundation

Progress Bar for execution in javascript

I need to show a progress bar using javascript if some execution is happening.
I saw example in student attendance tool, the code is:
frappe.confirm(__(“Do you want to update attendance?
Present: {0}

Absent: {1}”, [students_present.length, students_absent.length]),
function() { //ifyes
if(!frappe.request.ajax_count) {
frappe.call({
method: “erpnext.education.api.mark_attendance”,
freeze: true,
freeze_message: “Marking attendance”,
args: {
“students_present”: students_present,
“students_absent”: students_absent,
“student_group”: frm.doc.student_group,
“course_schedule”: frm.doc.course_schedule,
“date”: frm.doc.date
},
callback: function® {
$(me.wrapper.find(".btn-mark-att")).attr(“disabled”, false);
frm.trigger(“student_group”);
}
});
}
},
function() { //ifno
$(me.wrapper.find(".btn-mark-att")).attr(“disabled”, false);
}
);

And it works but when I used this same code it generates multiple confirmation windows instead of loader.
Can someone explain the logic of this code?