A
A
Alex Mirgorodskiy2018-03-20 18:07:27
JavaScript
Alex Mirgorodskiy, 2018-03-20 18:07:27

How to make an event after the creation of every 9th record?

Friends, how in Js you can make it so that when you add, say, every 9th record, this or that event occurs, another element is added to the page, for example. Only everything happens asynchronously, after each SMS added by ajax, you need to look, if it is the 9th, add an element to the page, if 18, then one more, and so on ... There are no static variables in js, how not to be tell?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Lezhnin, 2018-03-20
@AlexWeb6667

There are global variables.

var MyGlobalVariable = 0;
(function(){
  MyGlobalVariable ++;
  if(MyGlobalVariable % 9 == 0){
    alert('Супер приз!');
  }
})();

And so at any point in the js code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question