Results 1 to 3 of 3

Thread: clearInterval()

  1. #1
    ramjo_jeroe is offline Member
    Join Date
    Jun 2015
    Posts
    1
    Rep Power
    0

    Default clearInterval()

    Im totally green in coding but decided to learn.
    Im learning by making simple timers in my MUD game

    //This works perfectly:

    var nIntervId;

    nIntervId = setInterval(function(){gwc.connection.send('say hi');},5000);

    //it sends say hi to my mud client every 5 sec. So works as intended

    Question:

    Why canīt I clear the interval timer with the following?

    clearInterval(nIntervId);

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: clearInterval()

    Java != Javascript.

    You want to be looking for a Javascript forum.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: clearInterval()

    Assumption that this thread will be moved to the generic offtopic sections.

    Even in a javascript forum the answer is going to be "because you're doing something wrong". The singular lines of code are just fine, so the problem must be in in how and when you call those functions. Try some debugging with console.log() to see what code is and isn't called. Good luck.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •