I think I know the answer, but I just want to be 100% certain
Problem:
We have a PHP created webpage with an on-going Cost and an Available Options dropdown box. Each Available Option has a cost associated with it. The Cost is temporarily held in a MySQL database until the checkout phase.
My Boss wants the display of the Cost to be updated when the Available Options box value has been changed, all this without the webpage being refreshed in the browser, i.e. just the Cost value is updated from the MySQL database with the additional Available Option cost.
I am assuming that the only way is the AJAX route, is this correct, or is there a better solution?
It could be done purely via JavaScript. This would require that you provide all the necessary JS data during the initial page load in order for the JS to do the logic/math to adjust the price as options are changed. As to which is better (AJAX or JS-only), part of the answer might be how much data would need to be downloaded to the browser: a couple kilobytes, no big deal; a couple megabytes, big deal.
PS: Whichever approach you take, remember not to trust any price calculated on the browser side, as that can easily be changed by a hacker. You'll still have to recalculate it on the server side based on the quantity, options, item ID, etc. that the user selected.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
We only process the options selected, but the price is for the clients to view. Refresh is a none starter as it's an 'expensive objects' website. Refresh screen would not be acceptable to my Boss for a changing price
Size-wise, very image and flash centric , relatively slow load.
Bookmarks