Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8078903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:56:24+00:00 2026-06-05T15:56:24+00:00

i have a simple question, there is a function with parameter emp_id that opens

  • 0

i have a simple question, there is a function with parameter emp_id that opens up a form for a chat with different attributes, i want it to be refreshed automatically each 10 sec, now it works a bit wrongly, since there is a parameter emp_id that is can be changed, and once i change it, the chat with messages and form are refreshed double time or triple times 🙂 depend on how many times u change the emp_id, i hope i was clear )) anyway here is the javascript function:

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);
}

there a list of names, once i click on one of them, this form is opened by this function, but if i click another user, i mean if i change the emp_id, it refreshes, the previous and present form. how do i change it so that it will refresh only the last emp_id, but not all of id’s which i’ve changed

thank you all for the help, i really appreciate it!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:56:26+00:00Added an answer on June 5, 2026 at 3:56 pm

    This would nicely encapsulate what you’re doing. The timer id (tid) is kept inside the closure, so when you call load_chat it will stop the interval if there was one running.

    Once the new url is set up, it will start the interval timer again.

    var ChatModule = (function() {
        var tid,
        url;
    
        function refresh()
        {
            AjaxPageLoad(url, 'form_div', 1, 'Yükleniyor');
        }
    
        return {
            load_chat: function(emp_id) {
                if (tid) {
                    clearInterval(tid);
                }
                // setup url
                url = "#request.self#?fuseaction=objects2.popup_list_chatform"
                url = url + "&employee_id=" + emp_id;
                document.getElementById('form_div').style.display = 'block';
                // load ajax
                refresh();
                // set timer
                tid = setInterval(refresh, 10000);
            }
        }
    }());
    
    ChatModule.load_chat(123);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple question. I have this bitmap Is there a way with
I know this is a simple question for someone out there, but I have
I have a question, and I'm sure there is a relatively simple answer to
I have a simple question here. Is there a difference between passing a variable
Hey there- I'm testing jQuery Mobile and have a question. I wrote a simple
The problem is this: I want a generic function that has an out-parameter of
I have a fairly simple question about these 2 templating engines. I'm trying to
A very simple question. I have a html page which is divided into three
I have simple question. User supplies URL to my PHP script where I fetch
I have simple type Question : public class Question { public string[] Tags {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.