Javascript timer for different DOM events in single setInterval methodStop setInterval call in JavaScriptWhen to use double or single quotes in JavaScript?How to find event listeners on a DOM node when debugging or from the JavaScript code?Difference between == and === in JavaScriptWhat's the difference between using “let” and “var”?Remove all child elements of a DOM node in JavaScriptWhat is the difference between null and undefined in JavaScript?Pure JavaScript equivalent of jQuery's $.ready() - how to call a function when the page/DOM is ready for itJavascript setInterval not returning ID in a timely fashionHow to clear an interval that set inside another setInterval method in javascript

Coordinate position not precise

Why "be dealt cards" rather than "be dealing cards"?

Why are on-board computers allowed to change controls without notifying the pilots?

How will losing mobility of one hand affect my career as a programmer?

Confused about a passage in Harry Potter y la piedra filosofal

Your magic is very sketchy

Why did Kant, Hegel, and Adorno leave some words and phrases in the Greek alphabet?

How does it work when somebody invests in my business?

Student evaluations of teaching assistants

Have I saved too much for retirement so far?

How can I replace every global instance of "x[2]" with "x_2"

Generic lambda vs generic function give different behaviour

Efficiently merge handle parallel feature branches in SFDX

Why does John Bercow say “unlock” after reading out the results of a vote?

How to be diplomatic in refusing to write code that breaches the privacy of our users

Is HostGator storing my password in plaintext?

Is there any reason not to eat food that's been dropped on the surface of the moon?

Is there an Impartial Brexit Deal comparison site?

Curses work by shouting - How to avoid collateral damage?

Ways to speed up user implemented RK4

Is the destination of a commercial flight important for the pilot?

What would be the benefits of having both a state and local currencies?

Can I Retrieve Email Addresses from BCC?

How do I rename a LINUX host without needing to reboot for the rename to take effect?



Javascript timer for different DOM events in single setInterval method


Stop setInterval call in JavaScriptWhen to use double or single quotes in JavaScript?How to find event listeners on a DOM node when debugging or from the JavaScript code?Difference between == and === in JavaScriptWhat's the difference between using “let” and “var”?Remove all child elements of a DOM node in JavaScriptWhat is the difference between null and undefined in JavaScript?Pure JavaScript equivalent of jQuery's $.ready() - how to call a function when the page/DOM is ready for itJavascript setInterval not returning ID in a timely fashionHow to clear an interval that set inside another setInterval method in javascript













1















I am using setInterval to update 3 charts for 60 sec time of interval. So I created a global variable i.e. "Updatetimer" and called 3 charts seperately at the time of rendering of elements. So Now, My Charts are being updating in every 60 seconds(this is for "30mins" data).



So far this is good.



Now problem is coming when I am clicking one of the charts to render for different Time i.e for "24hrs" data. So what should happen is Updatetimer should update the data for 24hrs" data for 1st chart and continue on updating "30 mins" data for other two charts. but as I have calling all charts using single variable i.e. "UpdateTimer" On clearing "UpdateTimer" and calling setInterval for clicked event is simply fetching data for on 1st chart "30mins" data.



I tried to solve this by creating three different Timers for 3 charts and by running setInterval on them seperately, but this would update charts at different Time Interval and will make calls every now and then.



I want to come up with a solution where I can setInterval on charts at init and set the Interval on charts using single variable and when the is an event clicked on the DOM let say "24hrs" data of first chart is clicked. I want to set the update timer on the 1st chart without affecting other charts timer.



// Demo Code
function init()
updatetimer = setInterval(function() function A_30min(); function B_30min(); function C_30min() ,60000);


events:
"click .A_24" : "A_24hr" //lets say class selector is .A_24



function A_30min() //statement//
function A_24hr()
clearInterval(updatetimer);
setInterval(A_24hr, 60000);

function B_30min() //statement//
function B_24hr() //statement//
function C_30min() //statement//
function C_24hr() //statement//


Any help would be welcome, Thanks










share|improve this question
























  • No Actually what I want to do is that at the click event on "24hr" of 1st Chart, the chart should update data for 1st chart with 24hr data and continue running "30min" data for other two charts. This way all charts keep on updating data under single setInterval call

    – Asnau Nauticas
    Mar 4 at 18:20











  • Yes that's what I thought, but this would make request for each chart in different interval and all charts would be loading on different timers which wont look good to the user. Isnt it?

    – Asnau Nauticas
    Mar 4 at 18:23











  • ok, Do you have any other solution other than making 3 different Intervals? As I dont want chart to load on different timer as User will be able to see the latence in chart rendering at diffeerent Inteval

    – Asnau Nauticas
    Mar 4 at 18:29







  • 1





    Then that's completely different, :). What I would suggest in that case is to use a data element ( api.jquery.com/data ) on the charts, set them to the 30 or 24 or whatever to know what data to show, and in your interval when you get the data for each chart, check it's data field to know what you need to get

    – Taplar
    Mar 4 at 18:42






  • 1





    You won't change them in the interval, just check them. They will be set (I assume) on init() when the 30 interval starts, and change them when the user makes the different selection. All the interval has to do is grab the value for the chart it's trying to update at a time, and use it

    – Taplar
    Mar 4 at 18:47
















1















I am using setInterval to update 3 charts for 60 sec time of interval. So I created a global variable i.e. "Updatetimer" and called 3 charts seperately at the time of rendering of elements. So Now, My Charts are being updating in every 60 seconds(this is for "30mins" data).



So far this is good.



Now problem is coming when I am clicking one of the charts to render for different Time i.e for "24hrs" data. So what should happen is Updatetimer should update the data for 24hrs" data for 1st chart and continue on updating "30 mins" data for other two charts. but as I have calling all charts using single variable i.e. "UpdateTimer" On clearing "UpdateTimer" and calling setInterval for clicked event is simply fetching data for on 1st chart "30mins" data.



I tried to solve this by creating three different Timers for 3 charts and by running setInterval on them seperately, but this would update charts at different Time Interval and will make calls every now and then.



I want to come up with a solution where I can setInterval on charts at init and set the Interval on charts using single variable and when the is an event clicked on the DOM let say "24hrs" data of first chart is clicked. I want to set the update timer on the 1st chart without affecting other charts timer.



// Demo Code
function init()
updatetimer = setInterval(function() function A_30min(); function B_30min(); function C_30min() ,60000);


events:
"click .A_24" : "A_24hr" //lets say class selector is .A_24



function A_30min() //statement//
function A_24hr()
clearInterval(updatetimer);
setInterval(A_24hr, 60000);

function B_30min() //statement//
function B_24hr() //statement//
function C_30min() //statement//
function C_24hr() //statement//


Any help would be welcome, Thanks










share|improve this question
























  • No Actually what I want to do is that at the click event on "24hr" of 1st Chart, the chart should update data for 1st chart with 24hr data and continue running "30min" data for other two charts. This way all charts keep on updating data under single setInterval call

    – Asnau Nauticas
    Mar 4 at 18:20











  • Yes that's what I thought, but this would make request for each chart in different interval and all charts would be loading on different timers which wont look good to the user. Isnt it?

    – Asnau Nauticas
    Mar 4 at 18:23











  • ok, Do you have any other solution other than making 3 different Intervals? As I dont want chart to load on different timer as User will be able to see the latence in chart rendering at diffeerent Inteval

    – Asnau Nauticas
    Mar 4 at 18:29







  • 1





    Then that's completely different, :). What I would suggest in that case is to use a data element ( api.jquery.com/data ) on the charts, set them to the 30 or 24 or whatever to know what data to show, and in your interval when you get the data for each chart, check it's data field to know what you need to get

    – Taplar
    Mar 4 at 18:42






  • 1





    You won't change them in the interval, just check them. They will be set (I assume) on init() when the 30 interval starts, and change them when the user makes the different selection. All the interval has to do is grab the value for the chart it's trying to update at a time, and use it

    – Taplar
    Mar 4 at 18:47














1












1








1








I am using setInterval to update 3 charts for 60 sec time of interval. So I created a global variable i.e. "Updatetimer" and called 3 charts seperately at the time of rendering of elements. So Now, My Charts are being updating in every 60 seconds(this is for "30mins" data).



So far this is good.



Now problem is coming when I am clicking one of the charts to render for different Time i.e for "24hrs" data. So what should happen is Updatetimer should update the data for 24hrs" data for 1st chart and continue on updating "30 mins" data for other two charts. but as I have calling all charts using single variable i.e. "UpdateTimer" On clearing "UpdateTimer" and calling setInterval for clicked event is simply fetching data for on 1st chart "30mins" data.



I tried to solve this by creating three different Timers for 3 charts and by running setInterval on them seperately, but this would update charts at different Time Interval and will make calls every now and then.



I want to come up with a solution where I can setInterval on charts at init and set the Interval on charts using single variable and when the is an event clicked on the DOM let say "24hrs" data of first chart is clicked. I want to set the update timer on the 1st chart without affecting other charts timer.



// Demo Code
function init()
updatetimer = setInterval(function() function A_30min(); function B_30min(); function C_30min() ,60000);


events:
"click .A_24" : "A_24hr" //lets say class selector is .A_24



function A_30min() //statement//
function A_24hr()
clearInterval(updatetimer);
setInterval(A_24hr, 60000);

function B_30min() //statement//
function B_24hr() //statement//
function C_30min() //statement//
function C_24hr() //statement//


Any help would be welcome, Thanks










share|improve this question
















I am using setInterval to update 3 charts for 60 sec time of interval. So I created a global variable i.e. "Updatetimer" and called 3 charts seperately at the time of rendering of elements. So Now, My Charts are being updating in every 60 seconds(this is for "30mins" data).



So far this is good.



Now problem is coming when I am clicking one of the charts to render for different Time i.e for "24hrs" data. So what should happen is Updatetimer should update the data for 24hrs" data for 1st chart and continue on updating "30 mins" data for other two charts. but as I have calling all charts using single variable i.e. "UpdateTimer" On clearing "UpdateTimer" and calling setInterval for clicked event is simply fetching data for on 1st chart "30mins" data.



I tried to solve this by creating three different Timers for 3 charts and by running setInterval on them seperately, but this would update charts at different Time Interval and will make calls every now and then.



I want to come up with a solution where I can setInterval on charts at init and set the Interval on charts using single variable and when the is an event clicked on the DOM let say "24hrs" data of first chart is clicked. I want to set the update timer on the 1st chart without affecting other charts timer.



// Demo Code
function init()
updatetimer = setInterval(function() function A_30min(); function B_30min(); function C_30min() ,60000);


events:
"click .A_24" : "A_24hr" //lets say class selector is .A_24



function A_30min() //statement//
function A_24hr()
clearInterval(updatetimer);
setInterval(A_24hr, 60000);

function B_30min() //statement//
function B_24hr() //statement//
function C_30min() //statement//
function C_24hr() //statement//


Any help would be welcome, Thanks







javascript setinterval






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 5 at 10:53









T J

32.9k957112




32.9k957112










asked Mar 4 at 17:30









Asnau NauticasAsnau Nauticas

6511




6511












  • No Actually what I want to do is that at the click event on "24hr" of 1st Chart, the chart should update data for 1st chart with 24hr data and continue running "30min" data for other two charts. This way all charts keep on updating data under single setInterval call

    – Asnau Nauticas
    Mar 4 at 18:20











  • Yes that's what I thought, but this would make request for each chart in different interval and all charts would be loading on different timers which wont look good to the user. Isnt it?

    – Asnau Nauticas
    Mar 4 at 18:23











  • ok, Do you have any other solution other than making 3 different Intervals? As I dont want chart to load on different timer as User will be able to see the latence in chart rendering at diffeerent Inteval

    – Asnau Nauticas
    Mar 4 at 18:29







  • 1





    Then that's completely different, :). What I would suggest in that case is to use a data element ( api.jquery.com/data ) on the charts, set them to the 30 or 24 or whatever to know what data to show, and in your interval when you get the data for each chart, check it's data field to know what you need to get

    – Taplar
    Mar 4 at 18:42






  • 1





    You won't change them in the interval, just check them. They will be set (I assume) on init() when the 30 interval starts, and change them when the user makes the different selection. All the interval has to do is grab the value for the chart it's trying to update at a time, and use it

    – Taplar
    Mar 4 at 18:47


















  • No Actually what I want to do is that at the click event on "24hr" of 1st Chart, the chart should update data for 1st chart with 24hr data and continue running "30min" data for other two charts. This way all charts keep on updating data under single setInterval call

    – Asnau Nauticas
    Mar 4 at 18:20











  • Yes that's what I thought, but this would make request for each chart in different interval and all charts would be loading on different timers which wont look good to the user. Isnt it?

    – Asnau Nauticas
    Mar 4 at 18:23











  • ok, Do you have any other solution other than making 3 different Intervals? As I dont want chart to load on different timer as User will be able to see the latence in chart rendering at diffeerent Inteval

    – Asnau Nauticas
    Mar 4 at 18:29







  • 1





    Then that's completely different, :). What I would suggest in that case is to use a data element ( api.jquery.com/data ) on the charts, set them to the 30 or 24 or whatever to know what data to show, and in your interval when you get the data for each chart, check it's data field to know what you need to get

    – Taplar
    Mar 4 at 18:42






  • 1





    You won't change them in the interval, just check them. They will be set (I assume) on init() when the 30 interval starts, and change them when the user makes the different selection. All the interval has to do is grab the value for the chart it's trying to update at a time, and use it

    – Taplar
    Mar 4 at 18:47

















No Actually what I want to do is that at the click event on "24hr" of 1st Chart, the chart should update data for 1st chart with 24hr data and continue running "30min" data for other two charts. This way all charts keep on updating data under single setInterval call

– Asnau Nauticas
Mar 4 at 18:20





No Actually what I want to do is that at the click event on "24hr" of 1st Chart, the chart should update data for 1st chart with 24hr data and continue running "30min" data for other two charts. This way all charts keep on updating data under single setInterval call

– Asnau Nauticas
Mar 4 at 18:20













Yes that's what I thought, but this would make request for each chart in different interval and all charts would be loading on different timers which wont look good to the user. Isnt it?

– Asnau Nauticas
Mar 4 at 18:23





Yes that's what I thought, but this would make request for each chart in different interval and all charts would be loading on different timers which wont look good to the user. Isnt it?

– Asnau Nauticas
Mar 4 at 18:23













ok, Do you have any other solution other than making 3 different Intervals? As I dont want chart to load on different timer as User will be able to see the latence in chart rendering at diffeerent Inteval

– Asnau Nauticas
Mar 4 at 18:29






ok, Do you have any other solution other than making 3 different Intervals? As I dont want chart to load on different timer as User will be able to see the latence in chart rendering at diffeerent Inteval

– Asnau Nauticas
Mar 4 at 18:29





1




1





Then that's completely different, :). What I would suggest in that case is to use a data element ( api.jquery.com/data ) on the charts, set them to the 30 or 24 or whatever to know what data to show, and in your interval when you get the data for each chart, check it's data field to know what you need to get

– Taplar
Mar 4 at 18:42





Then that's completely different, :). What I would suggest in that case is to use a data element ( api.jquery.com/data ) on the charts, set them to the 30 or 24 or whatever to know what data to show, and in your interval when you get the data for each chart, check it's data field to know what you need to get

– Taplar
Mar 4 at 18:42




1




1





You won't change them in the interval, just check them. They will be set (I assume) on init() when the 30 interval starts, and change them when the user makes the different selection. All the interval has to do is grab the value for the chart it's trying to update at a time, and use it

– Taplar
Mar 4 at 18:47






You won't change them in the interval, just check them. They will be set (I assume) on init() when the 30 interval starts, and change them when the user makes the different selection. All the interval has to do is grab the value for the chart it's trying to update at a time, and use it

– Taplar
Mar 4 at 18:47













1 Answer
1






active

oldest

votes


















1














I have found an Answer other than using suggested data element of jquery.



What I did is created 3 global variable those are initializing with default events or property. Now when the page loads and renders the elements on DOM and lets say User clicked on any events on charts (suppose he/she clicked on 24hrs on chart1) So what I am doing is getting the click event from that event trigger and checking the triggered event with my global variable. So If my global variable is different than the click event, Global variable will change to the new click event triggered.



Now I am calling my functions based using setInterval and when functions are called it will check with the with new current clicked item, if it is clicked event it will call those API's otherwise Default one will be called.



Demo:

function init()
this.current_selected_chartA = "A_30";
this.current_selected_chartB = "B_30";
this.current_selected_chartC = "C_30";
updatetimer = setInterval(function() function A_30min(); function B_30min();
function C_30min() ,60000);

events:
"click .A_24, .A_30, .B_24, .B_30, .C_24, .C_30" : "clickEvent" //lets say user selects any of these selectors


clickEvent: function(event) {
if(event.currentTarget.attributes.name.value == "A_24")
this.current_selected_chartA = "A_24";
this.A();
this.B();
this.C();
setInterval(function() this.A();this.B();this.C();,60000);

else
//statement//
// same if condition will check current selected events for other events like A_30, B_30, B_24, C_30,and C_24.

function A() //statement//
if(this.current_selected_chartA == "A_30")
// callA_30 API's

else
// callA_24 API's


function B() //similar if else condition will follow for function B//
function C() //similar if else condition will follow for function B//





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54988540%2fjavascript-timer-for-different-dom-events-in-single-setinterval-method%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I have found an Answer other than using suggested data element of jquery.



    What I did is created 3 global variable those are initializing with default events or property. Now when the page loads and renders the elements on DOM and lets say User clicked on any events on charts (suppose he/she clicked on 24hrs on chart1) So what I am doing is getting the click event from that event trigger and checking the triggered event with my global variable. So If my global variable is different than the click event, Global variable will change to the new click event triggered.



    Now I am calling my functions based using setInterval and when functions are called it will check with the with new current clicked item, if it is clicked event it will call those API's otherwise Default one will be called.



    Demo:

    function init()
    this.current_selected_chartA = "A_30";
    this.current_selected_chartB = "B_30";
    this.current_selected_chartC = "C_30";
    updatetimer = setInterval(function() function A_30min(); function B_30min();
    function C_30min() ,60000);

    events:
    "click .A_24, .A_30, .B_24, .B_30, .C_24, .C_30" : "clickEvent" //lets say user selects any of these selectors


    clickEvent: function(event) {
    if(event.currentTarget.attributes.name.value == "A_24")
    this.current_selected_chartA = "A_24";
    this.A();
    this.B();
    this.C();
    setInterval(function() this.A();this.B();this.C();,60000);

    else
    //statement//
    // same if condition will check current selected events for other events like A_30, B_30, B_24, C_30,and C_24.

    function A() //statement//
    if(this.current_selected_chartA == "A_30")
    // callA_30 API's

    else
    // callA_24 API's


    function B() //similar if else condition will follow for function B//
    function C() //similar if else condition will follow for function B//





    share|improve this answer



























      1














      I have found an Answer other than using suggested data element of jquery.



      What I did is created 3 global variable those are initializing with default events or property. Now when the page loads and renders the elements on DOM and lets say User clicked on any events on charts (suppose he/she clicked on 24hrs on chart1) So what I am doing is getting the click event from that event trigger and checking the triggered event with my global variable. So If my global variable is different than the click event, Global variable will change to the new click event triggered.



      Now I am calling my functions based using setInterval and when functions are called it will check with the with new current clicked item, if it is clicked event it will call those API's otherwise Default one will be called.



      Demo:

      function init()
      this.current_selected_chartA = "A_30";
      this.current_selected_chartB = "B_30";
      this.current_selected_chartC = "C_30";
      updatetimer = setInterval(function() function A_30min(); function B_30min();
      function C_30min() ,60000);

      events:
      "click .A_24, .A_30, .B_24, .B_30, .C_24, .C_30" : "clickEvent" //lets say user selects any of these selectors


      clickEvent: function(event) {
      if(event.currentTarget.attributes.name.value == "A_24")
      this.current_selected_chartA = "A_24";
      this.A();
      this.B();
      this.C();
      setInterval(function() this.A();this.B();this.C();,60000);

      else
      //statement//
      // same if condition will check current selected events for other events like A_30, B_30, B_24, C_30,and C_24.

      function A() //statement//
      if(this.current_selected_chartA == "A_30")
      // callA_30 API's

      else
      // callA_24 API's


      function B() //similar if else condition will follow for function B//
      function C() //similar if else condition will follow for function B//





      share|improve this answer

























        1












        1








        1







        I have found an Answer other than using suggested data element of jquery.



        What I did is created 3 global variable those are initializing with default events or property. Now when the page loads and renders the elements on DOM and lets say User clicked on any events on charts (suppose he/she clicked on 24hrs on chart1) So what I am doing is getting the click event from that event trigger and checking the triggered event with my global variable. So If my global variable is different than the click event, Global variable will change to the new click event triggered.



        Now I am calling my functions based using setInterval and when functions are called it will check with the with new current clicked item, if it is clicked event it will call those API's otherwise Default one will be called.



        Demo:

        function init()
        this.current_selected_chartA = "A_30";
        this.current_selected_chartB = "B_30";
        this.current_selected_chartC = "C_30";
        updatetimer = setInterval(function() function A_30min(); function B_30min();
        function C_30min() ,60000);

        events:
        "click .A_24, .A_30, .B_24, .B_30, .C_24, .C_30" : "clickEvent" //lets say user selects any of these selectors


        clickEvent: function(event) {
        if(event.currentTarget.attributes.name.value == "A_24")
        this.current_selected_chartA = "A_24";
        this.A();
        this.B();
        this.C();
        setInterval(function() this.A();this.B();this.C();,60000);

        else
        //statement//
        // same if condition will check current selected events for other events like A_30, B_30, B_24, C_30,and C_24.

        function A() //statement//
        if(this.current_selected_chartA == "A_30")
        // callA_30 API's

        else
        // callA_24 API's


        function B() //similar if else condition will follow for function B//
        function C() //similar if else condition will follow for function B//





        share|improve this answer













        I have found an Answer other than using suggested data element of jquery.



        What I did is created 3 global variable those are initializing with default events or property. Now when the page loads and renders the elements on DOM and lets say User clicked on any events on charts (suppose he/she clicked on 24hrs on chart1) So what I am doing is getting the click event from that event trigger and checking the triggered event with my global variable. So If my global variable is different than the click event, Global variable will change to the new click event triggered.



        Now I am calling my functions based using setInterval and when functions are called it will check with the with new current clicked item, if it is clicked event it will call those API's otherwise Default one will be called.



        Demo:

        function init()
        this.current_selected_chartA = "A_30";
        this.current_selected_chartB = "B_30";
        this.current_selected_chartC = "C_30";
        updatetimer = setInterval(function() function A_30min(); function B_30min();
        function C_30min() ,60000);

        events:
        "click .A_24, .A_30, .B_24, .B_30, .C_24, .C_30" : "clickEvent" //lets say user selects any of these selectors


        clickEvent: function(event) {
        if(event.currentTarget.attributes.name.value == "A_24")
        this.current_selected_chartA = "A_24";
        this.A();
        this.B();
        this.C();
        setInterval(function() this.A();this.B();this.C();,60000);

        else
        //statement//
        // same if condition will check current selected events for other events like A_30, B_30, B_24, C_30,and C_24.

        function A() //statement//
        if(this.current_selected_chartA == "A_30")
        // callA_30 API's

        else
        // callA_24 API's


        function B() //similar if else condition will follow for function B//
        function C() //similar if else condition will follow for function B//






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 7 at 11:41









        Asnau NauticasAsnau Nauticas

        6511




        6511





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54988540%2fjavascript-timer-for-different-dom-events-in-single-setinterval-method%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            1928 у кіно

            Захаров Федір Захарович

            Ель Греко