I am currently working on a site that allows users to rent equipment. When the user wishes to add accessories to the current rent a pop up window will open with the accessories available for the equipment. When the user selects an accessory, i use a js function with ajax to validate the users input and to check the existence of the accessories in my database.
After this validation the pop up window closes and i need to start a mysql transaction to modify the accessories picked for the rented equipment. I need it to be a transaction because the user can cancel the rent at any moment and i need to "return" everything to the way it was before the rent.
So the question is, is it possible to handle mysql transactions using several php files with ajax?
No, you can't do it with mysql transactions because you will not be able to serialize a reference to the transaction or connection, and the transaction will either be rolled back or committed (not sure which, but I think it gets committed) when the script execution stops. This means that it will not work across multiple requests.
Instead of using transactions, a possible solution would be to update your schema to add a flag for "picked" accessories. When the customer selects them, set this flag. If they cancel, unset it.