Hey there, I have a question about a function that opens a chat form with different attributes when given an emp_id parameter. My goal is to have this form automatically refresh every 10 seconds. However, the current implementation is causing some issues. Whenever the emp_id parameter is changed, the chat messages and form are refreshed multiple times (double or triple), depending on how many times the emp_id is changed. Here is the JavaScript function in question:
function load_chat(emp_id) {
var url = "#request.self#?fuseaction=objects2.popup_list_chatform"
url = url + "&employee_id=" + emp_id;
document.getElementById('form_div').style.display = 'block'; AjaxPageLoad(url,'form_div',1,'Yükleniyor');
setInterval( function() {
load_chat(emp_id);
},10000);
}
When clicking on a user from a list of names, this form is opened using the above function. The issue arises when switching to another user by changing the emp_id, as it causes both the previous and current forms to refresh unnecessarily. How can I modify this behavior so that only the last emp_id value refreshes, instead of all previously changed ids?
Thank you for your assistance, I really appreciate it!