A
A
Artem Gartung2020-04-14 19:00:30
JavaScript
Artem Gartung, 2020-04-14 19:00:30

How to change data on a button?

Faced such a problem, there is a certain button in it data of 3 types is displayed: 1) send a request 2) timestamp (how much time is left) 3) get the result. All this is interconnected with the database.

I am very interested in the 2nd point (time stamp), how to make the data on the button updated (output time format: 00:00:00), i.e. so that the user can see how much time is left without refreshing the page.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hzzzzl, 2020-04-14
@hzzzzl

setInterval(updateKnopka, 1000)

function updateKnopka() { 
  /* раз в секунду меняет текст */
}

like this
https://codepen.io/jmikey/pen/tFHrp
of course, if the time somehow depends on how long the database will process the request, and the server sends the remaining time to the browser, then this complicates everything

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question