Tarciso Junior
Tarciso Junior

Reputation: 549

Right way to send LocalStorage to server side php

I´m writing an application using html5 localstorage. It´s a dinamic questionary witch is managed by a javascript engine. I need to storage the answers in a mysql database running php on the server side.

The solution i used was create a form with hidden inputs witch is dinamically created and filled by that javascript engine, so I post the form to server. Its working fine, but i´m wondering if that is correct.

There is a best way to do this ?

Upvotes: 0

Views: 646

Answers (1)

Halcyon
Halcyon

Reputation: 57703

Serialize all your data into a string, such as with JSON.stringify and send it to the server with an AJAX request.

Form-encoding can be problematic for some values, such as when you want to send an empty list.

Upvotes: 3

Related Questions