I believe that the interaction between these pages would be better in the server-side instead of trying to do client-side javascript.
You can store the results of these commands from page A on localStorage
or sessionStorage
, and get them on page B. Page B does what must be done and passes the result of operations to page C. Page C then returns to the user whether the operation was a success or not. There is one problem: this solution only works in one device, since the localStorage
and the sessionStorage
are unique to the browser’s Javascript engine and cannot be shared.
This is very similar to the MVC standard, but certainly only Javascript on client-side is not the best way to implement it. I recommend you take a look at some programming language that can run servers like PHP, Ruby or Java. If you want to continue using Javascript, I recommend Nodejs to be able to use Javascript on the server as well.
Seeing from your comments, you can make two pages:
- The page on the phone can send a command to the server;
- The server reads this command;
- Page B is periodically (every 5-10 seconds) asking the server for the result of the command. When this changes, the page changes its state.
This would be one of the many solutions that exist for your problem, and it is certainly not the best. I suggest you explain your problem a little better, and what more detail do you want to do.
One way is, I believe, not so complex, to use web sockets. Do you have at least one command and what would this processing be on page B? For example, explain a command, what should be on page A, what should be processed on page B, and what should be on page C.
– Woss
I changed the question with a very simple example, so I can already have the basis to do what I need.
– Leo Letto
Doubt: should page B necessarily exist? I don’t see why it should do this interface. The communication between A and C would be more interesting, perhaps.
– Woss
I pictured page B as some js script from page C, but if it can be a solution without it, there are no problems, page A will be on mobile, and C on the user’s desktop, I pictured B as the one that connects both.
– Leo Letto