Page 1 of 1

send localStorage value/array to external script/service

Posted: Fri Feb 27, 2015 11:09 pm
by Kristian Pettersen Granrud

Hi,

I have a localStorage, with value like this.

cars: [{"car":"Fiat"},{"car":"Ford"}]

What is the best way to send the value as an array to my PHP script?

The PHP script will then do stuffs with the array, eg. insert it into mySQL database and so on. My question is not about the PHP script, but how to send the value from my storage to that script.


send localStorage value/array to external script/service

Posted: Sat Feb 28, 2015 2:28 am
by Alena Prykhodko

Hello Kristian,

Unfortunately, I'm not familiar with such case, Appery.io uses pretty standard Local storage browser API.
Please search online for solutions.


send localStorage value/array to external script/service

Posted: Sat Feb 28, 2015 10:13 am
by Kristian Pettersen Granrud

Thanks for your reply Alene .

Perhaps I can get what I want in a different way too. I've tried to map this array to one of my databases in appery .

But only the first object enters the database.

Is there an easy way to get an array to be insertet into the database, one row for each "car" in the database. I have tried the mapping, but only one row got insertet.

Maybe a loop that returns a new database row for each "car" from my array? If so, where to write this js code with the loop, in the "custom js" in the mapping window, or as a javascript (event) trigged by e.g click on button?

A little explanation to the concept of the app:

The app works like a kind of todo app, but it works completely offline, and "todo" items are stored in an array, locally. When the list is complete , the app need the possibility to save the result into a database or sent to external service. In one single click.


send localStorage value/array to external script/service

Posted: Sun Mar 01, 2015 11:37 am
by Bob Fludder

Hi Kristian,
When you say you have tried mapping. Check what you're mapping. You're mapping a local storage field. Is the local storage defined as an array or a string ? What are you mapping it to ? And you're using a standard REST service to send the data ?

Hope this helps

Bob