PDA

View Full Version : Sending localStorage store models to a server?



Bucs
27 Mar 2011, 7:51 AM
I have a situation where an app uses a localStorage proxy to add Product models to a "Cart" store. Then, upon Checkout, I need to send these records (models) to the server to perform some processing. What is the recommended way to do this, given that the proxy that is currently tied to the cart store is aimed at localStorage, not a server storage proxy? I want to be able to send all the records in the localStorage to the server at once. Do I need to create a separate proxy that implements an Ajax proxy and somehow force the cart store to use this new proxy for updates or something?

A little confused on the best approach here. Thx.

jay@moduscreate.com
29 Mar 2011, 4:34 AM
I would simply collect the data from the local storage, and send via AJAX request over to the server. Upon success, apply changes to the local store model to keep things in sync.

Bucs
29 Mar 2011, 4:59 AM
Thanks J, I figured that would be the best option. In your opinion, what's the best way to send the store data, i.e. model collection, to the server? Simply Ext.encode the store.data property and POST as a field (so you're not limited by the querystring constraints)?

Thanks again!