K
K
Kirkl2014-04-20 14:59:50
JavaScript
Kirkl, 2014-04-20 14:59:50

How to organize the storage of a variable on the client side of the page?

Is it possible using javascript to store a variable on the client side that will increase when any user clicks on the button? That is, the first person entered and pressed send, the variable became equal to one, another person entered and sent - it became 2, etc. etc.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
C
callback, 2014-04-20
@Kirkl

Store the counter on another server. For example, there is a Firebase service ( firebase.com ) that provides 100 MB of free space in the database, 5 GB of traffic and a maximum of 50 simultaneous connections. If this suits you, then this is the simplest option, where the code will be reduced to

var i = 0;
var fb = new Firebase("https://YOUR.firebaseio.com/");
fb.on("value", function(data) { // чтение 
    i  = data.val().counter;
});
fb.set({ counter: i+1 }); // запись

D
DDanya, 2014-04-20
@DDanya

What you wrote is very stupid and impossible. Keep it on the server.

V
VeMax, 2014-04-20
@VeMax

If it is stored on the client side, then each client will have its own variable. Will have to store on the server.

A
Andrew Dabich, 2014-04-20
@dabich

If you are given such a task, then for the implementation you need to work with the server side. If there are no necessary accesses, you simply notify that it is impossible to do this for technical reasons, and this is no longer your problem.
But if you really need to do something, then perhaps on another server to work with this counter. Because the client side is individual and knows almost nothing about the outside world. The server part provides the general data. And nothing else.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question