0
votes

I'm trying to make a simple Sencha Touch App that submits a form with attached images, and stores the data in a remote MySQL database via PHP.

The user-inserted images are stored in a data store.

When the user clicks the submit button, I would like all the data in the store to be encoded into a JSON string which I can easily send to my database.

Is there any way to do this in Sencha Touch?

Thanks!

2

2 Answers

1
votes

Sencha Touch has the JSON lib included, you can encode in the following manner:

Ext.util.JSON.encode(formDataArray)

Also have a look at the Sencha Touch API Docs here: http://docs.sencha.com/touch/1-1/#!/api/Ext.util.JSON which references http://www.json.org/js.html

0
votes

You can encode image to Base64 string and when attached to your form you can store base64 string value in a hidden field in your form.

When user clicks submit button you retrieve values in your form using activePanel.getValues(false).This gives you JSON presentation of components you used in your form and their values.