3
The user is filling the cart with several items, and I created a jQuery function where the items are instantly added and presented to it. As soon as it finishes choosing the items and clicks on the Proceed button, the items and the value are saved in the database. But if it refreshes the page by pressing F5, or clicking on the browser image to refresh, the values and items are reset from the screen.
So far so good, the problem is are not zeroed from the bank, i would like to know how to identify this update, so I can work ajax and also erase the database data.
First: why would you like to erase the data if the user simply refreshes the page? Second: there is the event onbeforeunload, but it’s very limited, you can’t make asynchronous requests on your Handler.
– danguilherme
The idea would be to keep one
cookie
. If the page is being updated, thecookie
there is, otherwise no.– mutlei
Correct is only save in the bank after it update on the screen, so I understood you save as soon as the user type?
– PauloHDSousa
Open a session on the page whenever the user accesses, destroy and starte again whenever the page is updated and save it together in the database, whenever the page is updated destroy the session and create a new one, do not forget to capture.
– Daniel Gregatto
I would create an ajax to feed a php session each time an item is added. When loading the page (after F5), the session would be read in the predetermined fields. That is, you would have to work with js calculus and reading and writing session.
– Rodrigo Mello
Good people, sorry for the delay, a lot of work here, I managed to solve my problem, it was just a matter of logic. It’s just that at the moment you only think about wanting to solve, resolve and, ends up not resting the mind. Thank you all.
– Rafael Severino
If you do not want to spend spending request to add the items put them in a local session and when you want to save in the bank.
– Gabriel Rodrigues