Javascript that permanently changes server css

Asked

Viewed 84 times

0

First, I apologize if this question is too vague or stupid, but I really don’t have enough knowledge to formulate otherwise.

My idea is simple, create a site where, through Javascript, the visitor can, for example, drag and change the position of an element on the screen. But that this new position that the element has assumed is permanent, including for the next visitors of the page, and not just on the client side. I imagine then a script that changes positioning parameters in a css file on the server permanently.

Is it possible to do this only with Javascript? I imagine it is not possible for Javascript to normally be a client-side language. What other direction can I take, then?

  • Possible with JS is, but the "permanent" result will only be visible on the machine where the operation was made (i.e., it won’t be in the "server CSS", which in itself is a very vague statement). If that’s not what you want, better [Dit] the question and clarify with details. It is easier for you to describe the intention and purpose of the application you want to do, and not the way you are trying to do it.

  • This is possible with Javascript to drag and save the final position) and ajax (to talk to the server); some technology on the server to store that position. How is the question very broad. Could you [Edit] the question and start with one of the parts of Javascript.

  • While making a codepen to explain the application better, I found a solution: http://code.tutsplus.com/tutorials/simple-draggable-element-persistence-with-jquery--net-7474 Should I remove the question? Since the link solution solves my problem.

1 answer

0

The two main possibilities are:

  1. Create events in Javascript where, after the user makes a change, he makes an AJAX request, saving the values on the server as you see fit. Such values are restored when the page loads again.

  2. If the changes do not necessarily need to last a lifetime, you can use the localStorage to save the data in the browser and read whenever needed. However, the data will be lost if the user clears, switches browser, etc.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.